Example usage for org.apache.pdfbox.cos COSStream COSStream

List of usage examples for org.apache.pdfbox.cos COSStream COSStream

Introduction

In this page you can find the example usage for org.apache.pdfbox.cos COSStream COSStream.

Prototype

public COSStream(ScratchFile scratchFile) 

Source Link

Document

Creates a new stream with an empty dictionary.

Usage

From source file:eu.europa.ec.markt.dss.signature.pdf.pdfbox.PdfBoxStream.java

License:Open Source License

public PdfBoxStream(byte[] bytes) throws IOException {
    RandomAccessBuffer storage = new RandomAccessBuffer();
    this.wrapped = new COSStream(storage);
    final OutputStream unfilteredStream = this.wrapped.createUnfilteredStream();
    unfilteredStream.write(bytes);/*from   w w  w.  ja v  a2 s  .co  m*/
    unfilteredStream.flush();
}

From source file:eu.europa.esig.dss.pdf.pdfbox.PdfBoxSignatureService.java

License:Open Source License

private COSStream getStream(Map<String, COSStream> streams, Token token) throws IOException {
    COSStream stream = streams.get(token.getDSSIdAsString());
    if (stream == null) {
        RandomAccessBuffer storage = new RandomAccessBuffer();
        stream = new COSStream(storage);
        OutputStream unfilteredStream = stream.createUnfilteredStream();
        unfilteredStream.write(token.getEncoded());
        unfilteredStream.flush();//from www.  jav a2 s.co m
        streams.put(token.getDSSIdAsString(), stream);
    }
    return stream;
}

From source file:eu.europa.esig.dss.pdf.pdfbox.PdfBoxStream.java

License:Open Source License

public PdfBoxStream(byte[] bytes) {
    try {//from  ww w.j  ava2  s . co m
        RandomAccessBuffer storage = new RandomAccessBuffer();
        this.wrapped = new COSStream(storage);
        final OutputStream unfilteredStream = this.wrapped.createUnfilteredStream();
        unfilteredStream.write(bytes);
        unfilteredStream.flush();
    } catch (Exception e) {
        throw new DSSException(e);
    }
}

From source file:net.padaf.preflight.utils.TestCOSUtils.java

License:Apache License

@Test
public void testIsStream() {
    try {/*from  w w w  . jav  a 2 s. co  m*/
        COSObject co = new COSObject(new COSStream(null));
        co.setGenerationNumber(new COSInteger(0));
        co.setObjectNumber(new COSInteger(10));

        assertFalse(COSUtils.isStream(co, new IOCOSDocument()));

        COSDocument doc = new COSDocument();
        doc.setXRef(new COSObjectKey(co), 1000);
        COSUtils.isStream(co, doc);
        doc.close();
    } catch (IOException e) {
        fail(e.getMessage());
    }
}

From source file:org.apache.padaf.preflight.utils.TestCOSUtils.java

License:Apache License

@Test
public void testIsStream() {
    try {/*from  w w w.  j av  a 2  s  .com*/
        COSObject co = new COSObject(new COSStream(null));
        co.setGenerationNumber(COSInteger.ZERO);
        co.setObjectNumber(new COSInteger(10));

        assertFalse(COSUtils.isStream(co, new IOCOSDocument()));

        COSDocument doc = new COSDocument();
        addToXref(doc, new COSObjectKey(co), 1000);
        COSUtils.isStream(co, doc);
        doc.close();
    } catch (IOException e) {
        fail(e.getMessage());
    }
}