Feature for grouping multiple pages on single page in the pdf document

The library of PDF Creator Pilot has feature for combining 2, 3, 4, etc. pages in a single page in the pdf document. For this purpose, we added a function DrawPageOnPage, which has the following options:

srcPageIndex – Index of the source page;
destPageIndex – Index of the destination page;
left – The x-coordinate, in pixels, of the upper-left corner of the destination rectangle;
top – The y-coordinate, in pixels, of the upper-left corner of the destination rectangle;
width – The width, in pixels, of the destination rectangle;
height – The height, in pixels, of the destination rectangle.

An example of using this function. Assume that we have a pdf file with 4 pages and wish to draw  (group, fit) them on single page.

// PDF object is supposed to be created
// PDF file contains 4 pages A4
PDF->Open(“4pagesA4.pdf”, “”);

// Add a new page for drawing at end of document
PDF->NewPage();
PDF->PageSize = pfA4; // set any page size here

PDF->CurrentPage = 4; // index of new page
long height = PDF->PageHeight;
long width = PDF->PageWidth;

// Draw page on the page.
PDF->DrawPageOnPage(0, 4, 0.0, 0.0, width/2, height/2);
PDF->DrawPageOnPage(1, 4, width/2, 0.0, width/2, height/2);
PDF->DrawPageOnPage(2, 4, 0.0, height/2, width/2, height/2);
PDF->DrawPageOnPage(3, 4, width/2, height/2, width/2, height/2);

PDF->SaveToFile(“result.pdf”, true);

You may see the result of groupinf pages here: result.pdf

Artem Golubnichenko,
Two Pilots
http://www.colorpilot.com

Leave a Reply

Your email address will not be published.