pdfbox-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Pyeron (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (PDFBOX-4554) operations taking a byte[] need to allow for offset and length too
Date Fri, 31 May 2019 19:18:00 GMT

    [ https://issues.apache.org/jira/browse/PDFBOX-4554?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16853355#comment-16853355

Jason Pyeron commented on PDFBOX-4554:

why do you litter the code with new byte[] ? https://www.youtube.com/watch?v=j7OHG7tHrNM&t=44

use N ByteBuffer , 1 for each pair in the byte-range. that is what java.nio.ByteBuffer is

     * Return the signed content of the document. This is not a PDF file, nor is it the PDF
     * before signing, it is the byte sequence made of the input minus the area where the
     * bytes will be. See "The ByteRange and signature value" in the document
     * <a href="https://www.adobe.com/devnet-docs/acrobatetk/tools/DigSig/Acrobat_DigitalSignatures_in_PDF.pdf#page=5">Digital
     * Signatures in a PDF</a>.
     * @param pdfFile The signed pdf file as byte array
     * @param offset The offset in the pdfFile buffer of the first byte to read.
     * @param length The maximum number of bytes to read from the pdfFile buffer.
     * @return an array of ByteBuffer each containing the signed part of the content, altogether
the whole signed content is returned
     * @throws IOException if the pdfFile can't be read
    public ByteBuffer[] getSignedContents(byte[] pdfFile, int offset, int length) throws IOException
        int[] ranges = getByteRange();
        ByteBuffer[] res=new ByteBuffer[ranges.length/2];

        for (int i = 0; i<ranges.length/2; ++i)
            res[i]=ByteBuffer.wrap(pdfFile, offset+ranges[i*2], ranges[i*2+1]);
        return res;

> operations taking a byte[] need to allow for offset and length too
> ------------------------------------------------------------------
>                 Key: PDFBOX-4554
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4554
>             Project: PDFBox
>          Issue Type: Improvement
>            Reporter: Jason Pyeron
>            Priority: Major
> Without this, massive amounts of memory must be copied/allocated to "trim" byte[].
> See forthcoming pull request.

This message was sent by Atlassian JIRA

To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org

View raw message