Xojo Conferences
XDCMay2019MiamiUSA
MBSOct2019CologneDE

DynaPDF Manual - Page 533

Previous Page 532   Index   Next Page 534

Function Reference
Page 533 of 766
Special flags
The flag ofDeletePrivateData can be set to delete private data objects from pages, templates, and
images. Private data objects are created by several applications. For example, Adobe's Photoshop or
InDesign write the original images or PDF pages into private data structures (depending on the
settings in these applications).
A normal PDF viewer does not understand this data and ignores it. Because such objects are often
very large it is recommended to delete useless private data.
Recommendations
Optimize can do a lot but not anything. For example, the function does not perform a duplicate
check for images, templates, and other PDF objects like extended graphics states. Such a duplicate
check is available when importing a PDF file but not after the file was already imported. In addition,
the memory usage must be restricted. Optimize() can flush pages away after optimization but it is
also important to make sure that not too much memory will be consumed before the function is
called.
Therefore, the right flags must be used when importing a PDF file. Here are the default import flags
which should be used when optimizing PDF files:
pdfSetImportFlags(pdf, ifImportAll | ifImportAsPage);
pdfSetImportFlags2(pdf, if2UseProxy | if2DuplicateCheck);
The above flags avoid the conversion of pages to templates, the memory usage will be reduced, and
a duplicate check is applied on images, templates, extended graphics states, and several other PDF
objects which are often used.
Many other flags are available but the above flags can be used by default whenever a PDF file should
be optimized.
Error handling
This function adds warnings to the error log of DynaPDF. The error log can be accessed with
GetErrLogMessageCount() / GetErrLogMessage().
Return values:
If the function succeeds the return value is 1. If the function fails the return value is 0. No PDF file is
in memory if the function fails. Therefore, it is not required to call FreePDF() on failure.
 

Previous topic: Possible issues

Next topic: PageLink2