Example usage for com.itextpdf.text.pdf PdfStream NO_COMPRESSION

List of usage examples for com.itextpdf.text.pdf PdfStream NO_COMPRESSION

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfStream NO_COMPRESSION.

Prototype

int NO_COMPRESSION

To view the source code for com.itextpdf.text.pdf PdfStream NO_COMPRESSION.

Click Source Link

Document

A possible compression level.

Usage

From source file:org.h819.commons.file.MyPDFUtils.java

/**
 * ?pdf//www. j a va2  s .  co m
 *
 * @param srcPdfFile  the original PDF
 * @param descPdfFile the resulting PDF
 * @throws java.io.IOException
 * @throws DocumentException
 */
public static void decompressPdf(File srcPdfFile, File descPdfFile) throws IOException, DocumentException {

    if (srcPdfFile == null || !srcPdfFile.exists())
        throw new IOException("src pdf file '" + srcPdfFile + "' does not exsit.");

    PdfReader reader = getPdfReader(srcPdfFile);
    PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(descPdfFile.getAbsoluteFile()));
    stamper.getWriter().setCompressionLevel(PdfStream.NO_COMPRESSION);
    int total = reader.getNumberOfPages() + 1;
    for (int i = 1; i < total; i++) {
        reader.setPageContent(i, reader.getPageContent(i));
    }
    stamper.close();
    reader.close();

}