For the complete documentation index, see llms.txt. This page is also available as Markdown.

Optimize & compress PDFs using JavaScript

To optimize a PDF with default settings.

async function main() {
	const doc = await PDFNet.PDFDoc.createFromFilePath(filename);
	await PDFNet.Optimizer.optimize(doc);
}
PDFNet.runWithCleanup(main);

Compress & optimize PDF files Full code sample which shows how to use 'pdftron.PDF.Optimizer' to reduce PDF file size by removing redundant information and compressing data streams using the latest in image compression technology.

About optimize and compress

Compression as a subset of optimization represents encoding specific data using fewer bits than the original content by reducing the size of the data. This is distinct from optimize (which modifies all images) because you have the ability to choose individual images and to selectively choose the compression type for each.

Apryse SDK supports all basic and advanced compression filters allowed in PDF including:

  • JPEG2000

  • JBIG2

  • CCITT Fax

  • Flate/PNG

  • JPEG/DCT

  • Crypt Filters

Compress images in a PDF document

To compress images using JBIG2 compression inside a PDF.

PDF image JBIG2 compression Full sample code which illustrates how to recompress bitonal (black and white) images in existing PDF documents using JBIG2 compression.

Last updated

Was this helpful?