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

Tilman Hausherr commented on PDFBOX-4399:
-----------------------------------------

[~jjcool] there's a problem with this file that I found this morning and that 
wasn't in my test set. Page 2 has almost nothing rendered. It should display 
the Terms & Conditions in Czech language.

Possible cause, after reading the PDF specification:
{quote}When a piece of optional content in a PDF file is determined that it 
shall be hidden, the following occurs:
 •The content shall not be drawn.
 •Graphics state operations, such as setting the colour, transformation matrix, 
and clipping, shall still be applied. In addition, graphics state side effects 
that arise from drawing operators shall be applied; in particular, the current 
text position shall be updated even for text wrapped in optional content. In 
other words, graphics state parameters that persist past the end of a 
marked-content section shall be the same whether the optional content is 
visible or not.
 Hiding a section of optional content shall not change the colour of objects 
that do not belong to the same optional content group.
{quote}
Now here's a part of the content stream of page 2:
{code:java}
  /OC /MC3 BDC
  Q
  q
    0 0 595.276 841.89 re
    W
    n
    BT
      ...
    ET
  EMC
  /OC /MC4 BDC
    BT
      ...
    ET
  EMC
  /OC /MC5 BDC
    BT
...
{code}
MC3 and MC4 are hidden. So with the current code, "Q q" are lost so we're stuck 
with whatever has been set before. To test this theory, I added "q" and "Q" to 
{{isContentMarkOperator()}} and now it displays. But the real solution is of 
course more complex. I suspect one must investigate every method in PageDrawer 
to disable the actual drawing and keep the rest, e.g. clipping.

Another problem is on page 1. The two square radioboxes are rendered black, 
which didn't happen before.

I then tried another solution: let everything through and put {{if 
(isContentRendered())}} before every "graphics.fill", "graphics.stroke", 
"graphics.draw", and "graphics.drawImage", i.e. all graphics calls that "do 
something visible", and also skip form XObjects and transparency groups.

That looks nice, so I intend to do that soon.

We also need code to skip annotations (/OC entry). I am trying to find a test 
file.

> Disabled optional content groups are rendered
> ---------------------------------------------
>
>                 Key: PDFBOX-4399
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4399
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Rendering
>    Affects Versions: 2.0.6, 2.0.13
>            Reporter: Stefan Ziel
>            Priority: Major
>              Labels: OCGs
>             Fix For: 2.0.14, 3.0.0 PDFBox
>
>         Attachments: 1822-AGB.pdf, PDFBOX-4399-2.patch, gs.png, original.pdf, 
> printed.png
>
>
> Printing  a Documents with hidden optional content groups [^original.pdf] 
> renders hidden content [^printed.png]. Code used to print
> {code:java}
> InputStream sourceStream = new FileInputStream(pFile);
> try {
>   PDDocument source = PDDocument.load(sourceStream);
>   job.setPageable(new PDFPageable(source));
>   job.print(atts);
> } finally {
>   sourceStream.close();
> }
> {code}
> This is not only a problem of PDFBox ;) but can be done right ... ghostscript 
> does it [^gs.png].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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

Reply via email to