PDF support includes support for the PDF Compressor. Through MRC segmentation, this compressor can be used to break down a page/image into smaller segments, saving each segment using compression appropriate for that segment. Thus, one page of a PDF file may have an image JPEG compressed, some text JBIG2 compressed, Jpeg2000 compressed, and another area CCITT compressed. This whole process works to provide a PDF file with better compression and better quality than just a standard Raster PDF file.
The PDF Compressor is initialized by calling L_PdfCompInit. In addition to initializing the compressor, this function also creates an empty PDF file in memory and provides a handle to this new file. With a new PDF file created, the user may insert data to that new file. The user has the option of inserting material that has or has not been segmented using MRC Segmentation.
To insert data in the new PDF file that is MRC segmented, call L_PdfCompInsertMRC. This function will use MRC segmentation to segment the data, and will compress each segment using the most suitable compression, based on input and output profiles. Those profiles are provided in the imageQuality and outputQuality members of the PDFCOMPOPTIONS structure.
In addition to initializing the PDF Compressor, the L_PdfCompInit function also sets the callback function to use anytime MRC segmented data is inserted or saved using the L_PdfCompInsertMRC and L_PdfCompWrite functions. This callback function must adhere to the function prototype described in the pPDFCOMP_IMAGECALLBACK function.
To insert data that is not MRC segmented in the new PDF file, call L_PdfCompInsertNormal. This function compresses the input image as one image and inserts it in the PDF file in memory.
The L_PdfCompInsertSegments function applies a specified set of segments to a bitmap, then compresses and inserts the resulting image into the PDF file in memory.
The user can set the compression type to be used with each image segment inserted in the PDF file. To set the compression type, call the L_PdfCompSetCompression function.
This function must be called before inserting the compressed image into the PDF file by calling the following functions:
If the user does not call this function before using these methods, then the insertion process will use the default compression types.
After all data has been written to the file in memory, the file in memory should be written to a file on disk using L_PdfCompWrite. Once the file has been written to disk somewhere, the user must free the PDF document handle and all associated memory by calling L_PdfCompFree. Please note that if L_PdfCompFree is called before the file in memory has been written to a file on disk, the PDF file in memory will be destroyed and all the data in that file will be lost. This function should be the last function to be called in the PDF compressor functionality