Xojo Conferences
MBSOct2019CologneDE

DynaPDF Manual - Page 536

Previous Page 535   Index   Next Page 537

Function Reference
Page 536 of 770
an image will be scaled, it is possible that the color of certain pixels will be changed due to color
interpolation and this can lead to visible differences which are maybe not acceptable.
To avoid issues with masked images it is recommended to set the flag ofSkipMaskedImages.
Hairline correction
If the member MinLineWidth of the structure TOptimizeParams is greater zero the line width of
stroked paths will be set to MinLineWidth if the scaled value was smaller. The function considers all
transformations of the coordinate system.
The line width is measured in PDF units. One PDF unit represents 1/72 inch.
The minimum line width should be smaller or equal 1.0. The maximum value is 10.0 units.
Depending on the used flags it is possible to correct real hairlines only (zero width lines), all lines
which are thinner than MinLineWidth, or all lines with exception of real hairlines (line width = 0).
Possible issues
Hairline correction does not always produce the expected result, e.g. lines which look like a stroked
path are in fact filled rectangles. It is also possible that a surrounding clipping path prevents a visible
change of the line width.
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);
 

Previous topic: Color conversion, Converting gray images to 1 bit (black & white), Image scaling, Masked images (color key masking)

Next topic: Error handling