A PDF file consists of instructions to draw the page onto a screen. This is normally done by a computer program so it places a great deal of importance on how well written the drawing code is. The PDF file format includes a wide range of commands so that the key difference is often how well the drawing program makes use of different commands.
I was examining a PDF file last week which included a square box drawn with rounded corners. The PDF file format includes commands to draw lines and circle segments, so it can be draw with 4 line commands and 4 curve commands. Curves have start and end points and control points so they are easy to construct and change. This shape did not use curve commands though and instead used 200 line commands – the corners were drawn as a set of tiny lines which look like a curve. This matters for 3 reasons:-
1. It actually makes it harder to draw a smooth line. With a curve, the renderer can optimise the curve which is not possible with lots of smaller lines.
2. It makes a larger, slower file. The file is much larger and it will render slower.
3. The file is much harder to edit. Instead of 1 curve, you would need to hack the file if you wanted to alter the corners.
So you end up with the worst of all worlds – larger, slower files which are much harder to edit. How good are your PDF files?
This post is part of our “Understanding the PDF File Format” series. In each article, we discuss a PDF feature, bug, gotcha or tip. If you wish to learn more about PDF, we have 13 years worth of PDF knowledge and tips, so click here to visit our series index!
Latest posts by Mark Stephens (see all)
- Introducing the new XFA Parser in FormVu - May 16, 2018
- Moving to JPedal release 8 - May 2, 2018
- Which version of Java SE should I use? - April 25, 2018
- How we are improving our code quality with IDEA in 2018 - March 7, 2018
- How we are improving our code quality with NetBeans in 2018 - March 1, 2018