Example usage for com.lowagie.text Image setCompressionLevel

List of usage examples for com.lowagie.text Image setCompressionLevel

Introduction

In this page you can find the example usage for com.lowagie.text Image setCompressionLevel.

Prototype

public void setCompressionLevel(int compressionLevel) 

Source Link

Document

Sets the compression level to be used if the image is written as a compressed stream.

Usage

From source file:questions.compression.CompressionLevelsImage.java

public static void createPdf(int compressionLevel) {
    try {//from w w w  .j av  a  2 s.c om
        Document document = new Document();
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT[compressionLevel + 1]));
        writer.setCompressionLevel(compressionLevel);
        document.open();
        Image img = Image.getInstance(RESOURCE);
        img.setCompressionLevel(compressionLevel);
        document.add(img);
        document.close();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (DocumentException e) {
        e.printStackTrace();
    }
}