如何在Java中以编程方式减少PDF文件大小?

如何在Java中以编程方式减少PDF文件大小?

问题描述:

Document document = new Document(reader.getPageSizeWithRotation(1));
PdfCopy writer = new PdfCopy(document, new FileOutputStream(outFile));
document.open();
PdfImportedPage page = writer.getImportedPage(reader, ++i);
writer.setFullCompression();
writer.addPage(page);
document.close();
writer.close();

我使用iText分割和合并PDF,我需要你的帮助来减少(压缩)以编程方式输出PDF大小。请让我知道实现相同目标的步骤。

I am using iText to split and merger the PDF, I need your help to reduce (compress) the output PDF size programmatically. Please let me know the steps to achieve the same.

使用 writer.setFullCompression()您已尽可能压缩文件。使用iText,你无法做更多的事情。

With writer.setFullCompression() you already compressed file as much as possible. With iText you can't do anything more.