ImageGear improves the overall size of saved PDF documents by reducing or removing data structures in a PDF document.
File size improvements will vary with each PDF file. In some cases, file size reduction is dramatic. By default, ImageGear removes standard fonts embedded in a PDF document for additional compression benefits. Re-saving an optimized PDF file is not expected to further reduce its size. In rare instances, PDF file size may increase due to metadata that is always written when PDF documents are saved.
WARNING: Saving compressed may invalidate PDF/A and PDF/X compliant documents. Refer to API reference topic IG_PDF_save_compressed() for additional details.
To compress a PDF document using ImageGear:
- Create a handle to an HMIGEAR document using IG_mpi_create().
- Load the document using IG_mpi_file_open().
- Save the PDF to disk or memory using the IG_PDF_save_compressed() function.
The following is a sample function that illustrates how to save a highly-compressed PDF to disk:
C and C++ |
Copy Code
|
void SaveCompressedPDF(LPSTR lpInputFile, LPSTR lpOutputFile)
{
HMIGEAR pdfDocument;
IG_mpi_create(&pdfDocument, 0);
IG_mpi_file_open(lpInputFile, pdfDocument, IG_FORMAT_PDF, IG_MP_OPENMODE_READONLY);
AT_ERRCOUNT nErr = IG_PDF_save_compressed(pdfDocument, lpOutputFile);
IG_mpi_delete(pdfDocument);
}
|
Refer to the sample SaveCompressedPDF for a more complete example of re-saving PDF files (see PDF Samples).