Compress PDF Files
How to Shrink PDF File Size
Reduce PDF file size without losing overall quality with PDF compression. Define which content to preserve or discard, reduce image resolution while maintaining fidelity, and automate compression processing. Optimize documents for a wide range of workflows including faster opening and downloading, more efficient printing, and long-term preservation.
Get Free Trial
C++
C#
Java
C++
// Open the input PDF, set the default options, optimize it as a new PDF, then release the resources!
DURING
APDFLDoc inAPDoc("sample.pdf", true);
PDDoc inDoc = inAPDoc.getPDDoc();
PDFOptimizationParams optParams = PDDocOptimizeDefaultParams();
ASPathName outPathName = APDFLDoc::makePath("PDF-Optimizer-out.pdf");
PDDocumentOptimize(inDoc, outPathName, NULL, optParams, NULL, NULL, NULL, NULL);
ASFileSysReleasePath(NULL, outPathName);
PDDocOptimizeReleaseParams(optParams);
HANDLER
errCode = ERRORCODE;
libInit.displayError(errCode);
END_HANDLER
C#
// Open the input PDF, set the default options, optimize it as a new PDF!
using (Library lib = new Library())
using (Document doc = new Document("sample.pdf"))
using (Datalogics.PDFL.PDFOptimizer optimizer = new Datalogics.PDFL.PDFOptimizer())
optimizer.Optimize(doc, "PDFOptimizer-out.pdf");
Java
// Open the input PDF, set the default options, optimize it as a new PDF, then release the resources!
Library lib = new Library();
try
{
Document doc = new Document("sample.pdf");
PDFOptimizer optimizer = new PDFOptimizer();
try {
optimizer.optimize(doc, "PDFOptimizer-out.pdf");
}
finally
{
optimizer.delete();
}
}
finally
{
lib.delete();
}