Foxit PDF SDK 5.3

How to render only part of a PDF page?

To render only part of a PDF page, the key point is to ensure that the rendering page size is larger than the device’s display area. Contents that are not on the display area will not be rendered.

Foxit PDF SDK provides the interface FSPDF_Page_GetMatrix to get page’s transformation matrix
which can be used for rendering page to device’s context. Users can call
FSPDF_RenderContext_SetMatrix to set the matrix to a given rendering context.

Assuming that you have downloaded the trial package of Foxit PDF SDK, we can use the simple
samples as an example. To render only top-left 1/4 part of a PDF page, you can do as follows:

  • Go to “samples\simple_sample\comm_src\fgsdk_common.cpp” and locate the call of
  • Change the parameters of this interface to
    FSPDF_Page_GetMatrix (page, 0, 0, (FS_INT32) width*2, (FS_INT32) height*2, 0, &mt)”;
  • Build and run demo “pdf2img”.

Then check the generated files under “samples\simple_sample\output_files\pdf2img”, you
will find that only top-left 1/4 part of the PDF page has been rendered.

Following is the diagrams to further explain the processes above. Only the orange area in PDF page
will be rendered to device as shown in Figure 1(a). Figure 1(b) shows the display area in device
which has the same size with the page. Figure 2 shows that only the orange area has been rendered
in device by quadrupling the rendering page size.


FSPDF_Page_GetMatrix (FSCRT_PAGE page, FS_INT32 x, FS_INT32 y, FS_INT32 width, FS_INT32
height, FS_INT32 rotation, FSCRT_MATRIX *matrix)

Parameters x and y specify the location of the top-left point of a PDF page in device coordinate. For
example, setting (x, y) to (0, 0) means that the top-left point of the page just matches the origin in
device coordinate system; setting (x, y) to (-200, -100) means that the top-left point of the page is in
negative direction of x-axis by 200 and in negative direction of y-axis by 100 points of the origin in
device coordinate system.

Parameters width and height specify the rendering page size which may larger or smaller than the
actual size of a PDF page. For example, setting them to width*2 and height*2 means that the size of
the rendering page is four times as large as the actual one, but the actual page size has not been

Note: This article refers to a deprecated version of a Foxit Product. If you are still using Foxit PDF SDK 5.3 or older, please refer to your download package documents for Developer Guide and API Reference.

Get a trial version of the new Foxit PDF SDK and see our latest generation SDK’s brand new features!

Updated on March 26, 2017

Was this article helpful?
Thanks for your feedback. If you have a comment on how to improve the article, you can write it here: