DynaPDF Manual - Page 539

Previous Page 538   Index   Next Page 540

Function Reference
Page 539 of 777
// Minimum resolution before scaling.
// 1 bit black & white images.
// Gray images.
ResColorImages; // Multi-channel images.
TCompressionFilter Filter1Bit;
// Filter for black & white images.
TCompressionFilter FilterGray;
// Filter for gray images.
TCompressionFilter FilterColor;
// Filter for multi-channel images.
// JPEG quality.
// JPEG 2000 quality.
// Zero means no hair line removal.
The function rebuilds the content streams of all pages, templates, annotations, and form fields.
Useless operators as well as errors in content streams will be fully removed. The resulting content
streams are error free and usually smaller. How much the optimization takes effect depends on the
quality of the original content streams.
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.
Re-compressing 1 bit images with JBIG2
If the flag ofCompressWithJBIG2 is set, 1 bit images will be re-compressed with JBIG2 (if the image
was not already compressed with this filter). This can drastically reduce the file size since JBIG2
compression achieves much higher compression rates than any other 1 bit image filter that PDF
supports. The JBIG2 compression filter in DynaPDF is lossless, that means the original image quality
will be preserved.

Previous topic: Optimize

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