Some clarifications regarding PDF page boxes (MediaBox, CropBox, TrimBox, ArtBox).

Q: I have a question regarding PDF’s which I cannot find an answer to
in the PDF reference documentation and thought you may know how to
handle this. In certain cases I would like to enlarge the white space
border around the media box in a PDF. I have successfully been able to
this by manually adjusting the coordinates for a media box and by also
using SetBox in PDFTron. However I also find that if a CropBox is
defined, my method does not work. After further trial and error I
found that if I set the CropBox coordinates equal to the new MediaBox
coordinates, it works.
My question is if other “boxes” exist (BleedBox, TrimBox and Artbox)
do they all need to be set to the MediaBox coordinates in order to
realize an enlarged border in the pdf? My thought was to use GetBox to
see what “boxes” exist and then set them all to the new MediaBox

As a follow up to the above, I have tried to implement my idea of
“getting” all boxes in a pdf, and setting them to the coordinates of
the MediaBox but I have run into a curious behavior of GetBox. Using
the code below I always get values for all boxes (same values). I
looked into the pdf and only a Media Box and CropBox exist. Is there a
reason why I get values for BleedBox, TrimBox and ArtBox?

I appreciate any insight you may have regarding this question.
A: PDF page boxes are described in Section 14.11.2 'Page Boundaries'
in PDF Reference Manual (

"A PDF page may be prepared either for a finished medium, such as a
sheet of paper, or as part of a prepress process in which the content
of the page is placed on an intermediate medium, such as film or an
imposed reproduction plate. In the latter case, it is important to
distinguish between the intermediate page and the finished page. The
intermediate page may often include additional production-related
content, such as bleeds or printer marks, that falls outside the
boundaries of the finished page. To handle such cases, a PDF page may
define as many as five separate boundaries to control various aspects
of the imaging process:

- The media box defines the boundaries of the physical medium on which
the page is to be printed. It may include any extended area
surrounding the finished page for bleed, printing marks, or other such
purposes. It may also include areas close to the edges of the medium
that cannot be marked because of physical limitations of the output
device. Content falling outside this boundary may safely be discarded
without affecting the meaning of the PDF file.

- The crop box defines the region to which the contents of the page
shall be clipped (cropped) when displayed or printed. Unlike the other
boxes, the crop box has no defined meaning in terms of physical page
geometry or intended use; it merely imposes clipping on the page
contents. However, in the absence of additional information (such as
imposition instructions specified in a JDF or PJTF job ticket), the
crop box determines how the page’s contents shall be positioned on the
output medium. The default value is the page’s media box.

- The bleed box (PDF 1.3) defines the region to which the contents of
the page shall be clipped when output in a production environment.
This may include any extra bleed area needed to accommodate the
physical limitations of cutting, folding, and trimming equipment. The
actual printed page may include printing marks that fall outside the
bleed box. The default value is the page’s crop box.

- The trim box (PDF 1.3) defines the intended dimensions of the
finished page after trimming. It may be smaller than the media box to
allow for production-related content, such as printing instructions,
cut marks, or colour bars. The default value is the page’s crop box.

- The art box (PDF 1.3) defines the extent of the page’s meaningful
content (including potential white space) as intended by the page’s
creator. The default value is the page’s crop box.

The page object dictionary specifies these boundaries in the MediaBox,
CropBox, BleedBox, TrimBox, and ArtBox entries, respectively (see
Table 30). All of them are rectangles expressed in default user space
units. The crop, bleed, trim, and art boxes shall not ordinarily
extend beyond the boundaries of the media box. If they do, they are
effectively reduced to their intersection with the media box. Figure
86 illustrates the relationships among these boundaries. (The crop box
is not shown in the figure because it has no defined relationship with
any of the other boundaries.)

How the various boundaries are used depends on the purpose to which
the page is being put.

Most PDF viewers (including pdftron.PDF.PDFView) display pages as
intersection between crop and media box.

Please keep in mind that even though a specific page box is not
specified in the page dictionary it does have a default value (which
is returned your call to page.GetBox(type) method).
If you would like to check whether a page contains a given box type
you could use the following snippet:

Obj b = page.FindInheritedAttribute("CropBox");
if (b != null) {
  ... page contains a non-default Media box...

b = page.FindInheritedAttribute("TrimBox");
if (b != null) {
  ... page contains a non-default Trim box...