Example usage for com.lowagie.text.pdf PdfObject STREAM

List of usage examples for com.lowagie.text.pdf PdfObject STREAM

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfObject STREAM.

Prototype

int STREAM

To view the source code for com.lowagie.text.pdf PdfObject STREAM.

Click Source Link

Document

A possible type of PdfObject

Usage

From source file:es.gob.afirma.signers.pades.ltv.PdfDocumentSecurityStore.java

License:Open Source License

private static byte[] getContentBytesFromContentObject(final PdfObject contentObject) throws IOException {
    switch (contentObject.type()) {
    case PdfObject.INDIRECT:
        return getContentBytesFromContentObject(PdfReader.getPdfObject(contentObject));
    case PdfObject.STREAM:
        return PdfReader.getStreamBytes((PRStream) PdfReader.getPdfObject(contentObject));
    case PdfObject.ARRAY:
        final ByteArrayOutputStream allBytes = new ByteArrayOutputStream();
        final ListIterator<PdfObject> iter = ((PdfArray) contentObject).listIterator();
        while (iter.hasNext()) {
            allBytes.write(getContentBytesFromContentObject(iter.next()));
            allBytes.write((byte) ' ');
        }/* ww  w .java 2  s  .com*/
        return allBytes.toByteArray();
    default:
        throw new IllegalStateException("No se soporta contenido del tipo: " + contentObject.getClass()); //$NON-NLS-1$
    }
}