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

Tilman Hausherr commented on PDFBOX-2660:
-----------------------------------------

The file from PDFBOX-2521.pdf has the same problem.

IMO the real solution would be to find a way save the graphics stack (and not 
just the graphics state), and start rendering the annotation with a new 
graphics stack, and restore the stack afterwards. Alternatively find a way to 
protect the graphics stack against "too much pop" and to restore the stack to a 
certain level if there weren't enough pop operations in a stream.

This second best solution is this code in PageDrawer.showAnnotation that works 
for me and has no regressions (it replaces "super.showAnnotation(annotation);"):
{code}
            int oldGraphicsStackSize = getGraphicsStackSize();
            super.showAnnotation(annotation);
            while (getGraphicsStackSize() > oldGraphicsStackSize)
            {
                // todo warning msg
                restoreGraphicsState();
            }
            if (oldGraphicsStackSize != getGraphicsStackSize())
            {
                // todo warning msg
            }
{code}


> Text missing
> ------------
>
>                 Key: PDFBOX-2660
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2660
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Rendering
>    Affects Versions: 2.0.0
>            Reporter: simon steiner
>            Assignee: John Hewson
>             Fix For: 2.0.0
>
>         Attachments: PDFBOX-2660_unc.pdf, out2.pdf
>
>
> java -jar ~/pdf-box-svn/app/target/pdfbox-app-2.0.0-SNAPSHOT.jar PDFToImage 
> out2.pdf



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to