What is PDF pagesize?

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!

Related Posts:

The following two tabs change content below.

Mark Stephens

System Architect and Lead Developer at IDRSolutions
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.
Markee174

About 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.

2 thoughts on “What is PDF pagesize?

  1. Nörgler

    It’s [0 0 595 842], and not “0,0,795,842” as you write most incorrectly.
    (note the first “5” !)

    • Thanks for spotting the typo. I have updated the article.

Leave a Reply

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

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>