Mark Stephens

Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX.

He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

3 reasons why PDF commands inside a PDF matter

1 min read

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!

Mark Stephens

Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX.

He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

Pros and Cons of Bitbucket Pipelines

Recently I have been looking at our current test suite looking for ways to improve our own tests. As we use Bitbucket we have...
Kieran France
3 min read

Leave a Reply

Your email address will not be published. Required fields are marked *