Xojo Conferences
MBSOct2019CologneDE

DynaPDF Manual - Page 480

Previous Page 479   Index   Next Page 481

Function Reference
Page 480 of 767
Example 2:
PDF files can be merged as follows:
pdfOpenImportFile(pdf, "c:/test1.pdf");
SI32 nextPage;
// We avoid the conversion of pages to templates in this case.
pdfSetImportFlags(ifImportAll | ifImportAsPage);
nextPage = pdfImportPDFFile(pdf, 1, 1.0, 1.0); // Start import at page one
// The previous PDF file will be automatically closed.
pdfOpenImportFile(pdf, "c:/test2.pdf");
// Add the new file behind the previous one.
pdfImportPDFFile(pdf, nextPage + 1, 1, 1);
pdfCloseImportFile(pdf);
Imported pages are converted to templates by default. This conversion is done by default mainly to
achieve the same runtime behaviour in comparison to older versions of DynaPDF and to enable
scaling of PDF pages (scaling is only possible with templates). So, if you want to scale the pages to
another page format then the conversion of pages to templates is required.
However, in most cases scaling is not required. The conversion of pages to templates should be
avoided in this case by setting the flag ifImportAsPage:
pdfSetImportFlags(pdf, ifImportAll | ifImportAsPage);
The advantage is that non-converted pages are a little bit smaller and a PDF file can be imported and
written to disk arbitrary often without increasing the file size or the nesting depth of templates.
Especially the nesting depth of templates can be an important aspect if a PDF file must edited
multiple times. Note that each time a PDF file is imported, while pages are converted to templates,
the nesting depth of templates becomes incremented. So, if you would import and save a PDF file in
a loop, while each time pages are converted to templates, the resulting PDF file becomes larger and
larger, and the nesting depth of templates becomes higher and higher. A nesting depth of more than
8 can already cause printing problems. Viewer applications support usually much higher nesting
depths but the memory usage becomes then very large and the rendering speed is decreased.
Return values:
If the function succeeds the return value is the last page number that was touched. For example, if
the document in memory contains already 20 pages, and if we import a PDF file with 23 pages, and if
the destination page is 21 the return value should be 43 because this is the last page that was invoked
during import.
If the function fails the return value is a negative error code.
 

Previous topic: ImportPDFFile

Next topic: InitColorManagementEx