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!
Did you know...
IDRsolutions offers a whole range of online file converters to convert PDF and Microsoft Excel, Word and Office Documents to HTML5, SVG or image formats?
It is free to use for single file conversions and also includes Developer links if you want to use our commercial software for bulk conversions. Find out more on this page