//--------------------------------------------------------------------------------------- // Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved. // Consult legal.txt regarding legal and license information. //--------------------------------------------------------------------------------------- #include #include #include #include #include #include #include "../../LicenseKey/CPP/LicenseKey.h" using namespace std; using namespace pdftron; using namespace Common; using namespace SDF; using namespace PDF; //----------------------------------------------------------------------------------- // The sample illustrates how multiple pages can be combined/imposed // using PDFNet. Page imposition can be used to arrange/order pages // prior to printing or to assemble a 'master' page from several 'source' // pages. Using PDFNet API it is possible to write applications that can // re-order the pages such that they will display in the correct order // when the hard copy pages are compiled and folded correctly. //----------------------------------------------------------------------------------- int main(int argc, char *argv[]) { int ret = 0; PDFNet::Initialize(LicenseKey); const char* resource_path = argc>3 ? argv[3] : "../../../resources"; // Relative path to the folder containing test files. string input_path = "../../TestFiles/newsletter.pdf"; string output_path = "../../TestFiles/Output/newsletter_booklet.pdf"; try { cout << "-------------------------------------------------" << endl; cout << "Opening the input pdf..." << endl; const char* filein = argc>1 ? argv[1] : input_path.c_str(); const char* fileout = argc>2 ? argv[2] : output_path.c_str(); PDFDoc in_doc(filein); in_doc.InitSecurityHandler(); // Create a list of pages to import from one PDF document to another. vector import_pages; for (PageIterator itr=in_doc.GetPageIterator(); itr.HasNext(); itr.Next()) import_pages.push_back(itr.Current()); PDFDoc new_doc; vector imported_pages = new_doc.ImportPages(import_pages); // Paper dimension for A3 format in points. Because one inch has // 72 points, 11.69 inch 72 = 841.69 points Rect media_box(0, 0, 1190.88, 841.69); double mid_point = media_box.Width()/2; ElementBuilder builder; ElementWriter writer; for (size_t i=0; i