Xojo Conferences

DynaPDF Manual - Page 521

Previous Page 520   Index   Next Page 522

Function Reference
Page 521 of 750
Besides content optimization it is also possible to flatten layers, scale or just re-compress images, or
to correct hairlines.
The parameter Flags is a bit mask. Multiple flags can be combined with a binary or operator, e.g.
ofInMemory | ofScaleImage.
The flag ofScaleImages will be ignored if the parameter Parms is set to NULL.
Optimize() does not rebuild font subsets like CheckConformance(). The function is part of DynaPDF
It is assumed that this function is called right before closing the PDF file. It is not allowed to call the
function twice for the same PDF file in memory.
After Optimize() was executed, close the file with CloseFile(), CloseFileEx(), or CloseAndSignFile()
for example.
If the flag ofInMemory is absent, then pages are directly written to the output file after optimization
to reduce the memory usage. If the PDF file was created in memory (this is the case if no ouput file
name was passed to CreateNewPDF()) then the output file must be opened with OpenOutputFile()
or OpenOutputFileEncrypted() beforehand. Note that it is not possible to sign the PDF file if the flag
ofInMemory is absent.
If the file should be signed too, then import the resulting PDF file again and sign it with
CloseAndSignFile() or CloseAndSignFileEx() for example.
Image scaling
If the flag ofScaleImages is set, the function scales imported images according to the settings in the
TOptimizeParams structure. The function distuingishes between 1 bit, gray, and color images. The
minimum resolution of the original image that must be reached before scaling is applied can be set
for these three image types independently.
The minimum resolution of 1 bit images should be around 50% higher as the destination resolution
because scaling of 1 bit images can cause significant loss of quality if the original resolution is near
the destination resolution.
The minimum resolution of gray and color images can be freely chosen. 1 means scale all images.
The function scales images only if the minimum resolution is greater zero.
Images wich use a special color space like Separation, DeviceN, NChannel, or Lab cannot be scaled.
Such images are left unchanged.
The function checks whether the new image is smaller as the original one. If no size reduction can be
achieved then the image is stored as is.
The size check can be disabled with the flag ofNoImageSizeCheck.
Images which were inserted with DynaPDF functions like InsertImage() will be ignored.

Previous topic: Optimize

Next topic: Recommendations