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

Alban Fonrouge commented on PDFBOX-5366:
----------------------------------------

Hi, I looked more at the PDF and there is an incorrect stream in one of the 
Form, which causes an IOException, which is catched too late and screws up the 
push/pop mechanism.

I can suggest a fix:
{code:java}
private void processStreamOperators(PDContentStream contentStream) throws 
IOException {
    List<COSBase> arguments = new ArrayList<COSBase>();
    PDFStreamParser parser = new PDFStreamParser(contentStream);
    try {
        Object token = parser.parseNextToken();
        while (token != null) {
            if (token instanceof Operator) {
                processOperator((Operator) token, arguments);
                arguments.clear();
            } else {
                arguments.add((COSBase) token);
            }
            token = parser.parseNextToken();
        }
    } catch (IOException e) {
        LOG.warn("Error while parsing stream, stopping processing", e);
    }
}
 {code}
I will open another issue for the root cause of the parsing error.

> Unhandled IOException thrown from BaseParser creates issue in 
> PDFStreamEngine.processStreamOperators
> ----------------------------------------------------------------------------------------------------
>
>                 Key: PDFBOX-5366
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5366
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 2.0.25
>            Reporter: Alban Fonrouge
>            Priority: Major
>
> We had a document where the fonts were listed in PDFDebugger under Page: 1 / 
> Resources / Fonts, but not found during rendering.
> The issue is in SetFontAndSize, which should also check the resources at the 
> page level. I have attached a patch, but cannot provide a test file as this 
> was a confidential file.
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to