Example usage for org.apache.pdfbox.filter JBIG2Filter JBIG2Filter

List of usage examples for org.apache.pdfbox.filter JBIG2Filter JBIG2Filter

Introduction

In this page you can find the example usage for org.apache.pdfbox.filter JBIG2Filter JBIG2Filter.

Prototype

JBIG2Filter

Source Link

Usage

From source file:com.pnf.plugin.pdf.filter.JBIG2Decode.java

License:Apache License

public byte[] decodeBytes(byte[] data, int fromByte, int length, PdfDictionary dictionary)
        throws FilterStreamException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ByteArrayInputStream bais = new ByteArrayInputStream(data, fromByte, length);
    try {//  w  w  w  .ja  v a  2  s  .  c om
        new JBIG2Filter().decode(bais, baos, PDFObject.getInstance(dictionary),
                PDFObject.getInstance(decodeParms));
        return baos.toByteArray();
        // https://github.com/katjas/PDFrenderer fork of pdf-renderer use jpedal where license seems commercial
        // return new JBig2Decode().decode(PDFObject.getInstance(decodeParms),
        // ByteBufferUtils.getByteArray(data, fromByte, length).toByteArray());
    } catch (IOException e) {
        throw new FilterStreamException(e);
    }
}