Calculating the size of a PDF image

If you decide to include PDF graphic images within a document processed by TopLeaf, it is important to remember that only the first page of the PDF can be included, and that you may need to take steps to include the appropriate part of the page.

To select the appropriate part of the image you can use one of the following boundary boxes that can be defined on a PDF page.

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 can safely be discarded without affecting the meaning of the PDF file.

The crop box defines the region to which the contents of the page are to 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, the crop box determines how the page’s contents are to be positioned on the output medium. The default value is the page’s media box.

The art box is an arbitrary region that can be used to identify the important part of the page.

The following list describes the precedence rules that TopLeaf uses to determine the dimensions of an embedded PDF image:

  • If the art box dimensions are defined, then Topleaf will use these to determine the extent of the page content;

  • If the crop box dimensions are defined, then Topleaf will use these to determine the extent of the page content;

  • otherwise, TopLeaf will use the media box dimensions to determine the extent of the page content.

You can use the <image-properties/> directive to override this behavior and select a preferred PDF image bounding box.

Unfortunately, there is no hard and fast rule as to which of these boundary types is the most suitable for a particular PDF image. Often, the media box specifies the target page dimensions (for example, A4 or Legal), this means that the selected image dimensions can include a considerable amount of surrounding white space, whereas the crop box usually describes the portion of the page that contains the true page content.

It must be noted that the crop box and art box are optional PDF features that may not be present in all PDF files. In some cases, the TopLeaf PDF image processor can produce unexpected image clipping when rendering PDF images that rely on the PDF art box to declare the dimensions of the true page content.

It is the user's responsibility to ensure that if an embedded PDF image declares any of these boundary types, then the declared dimensions properly describe the portion of the page that contains the true page content. If rendering a PDF image produces an unexpected result, use an alternative scalable graphic format, such as EPS or SVG.