Page size can cause some confusion with PDFs because there are several possible values.
All PDF files have a MediaBox which defines the size of the PDF in units. Values 0,0,595,842 (listed in the file as an Array [0 0 595 842]) are the normal values for an A4 portrait page, although they can also be any custom settings. The values define a rectangle and can also be converted into inches/centimetres (Adobe Acrobat does this). Values can even be negative – although that is a little unusual.
Sometimes though, a PDF file might also have a CropBox value. This is usually the same size or smaller than the MediaBox. In this case, the CropBox is actually the page size you will see – it is the visible page area. Things can still be drawn on the area of the MediaBox but will not generally be visible.
The are several reasons why this happens. The most likely is that with its origins in the print industry, page are often created bigger than the final output to allow room for CMYK color boxes, Crop marks, etc.
So always take the CropBox if present – otherwise look at the MediaBox to see the actual page size.
For completeness, you can also have an option ArtBox, BleedBox and TrimBox, but if you do not already know what these are you do not need to and can generally ignore them.
The PDFReference guides from Adobe are usually good examples of a CropBox and MediaBox and the screenshots show the figures converted in Adobe Acrobat and unconverted in JPedal PDF Viewer.
This post is part of our “Understanding the PDF File Format” series. In each article, we aim to take a specific PDF feature and explain it in simple terms. 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)
- 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
- 3 ways that the European Union is changing the way Companies write software in 2018 - January 31, 2018
- IDRsolutions product range update for 2018 - January 22, 2018
- 4 ways Companies can make remote working successful - December 21, 2017