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

Adam Nichols commented on PDFBOX-866:
-------------------------------------

The problem in PDFBOX-99 was that this information was not getting encrypted; 
this is not the case here... it is getting encrypted, but it's not being 
encrypted properly.  For the "TL;DR" people, I'm close to having this solved.

I'll step through the HelpOrderingAppraisal_page1.unc.pdf to explain the bug 
and how it was fixed.  In this PDF object 18 is the image and the colorspace is 
21.  This makes sense.  When PDFBox writes out the image, the image is written 
out with the colorstream at both included in the same object (object id: 34).  
However, there's another ColorSpace which is associated with this image.  
Object 7 is references Object 19 as its XObject and that maps /R17 to our image 
(object 34).  At the same time, there's also a colorspace associated with 
object 7, which is object 17.  What happens in the code is that it encrypts the 
colorspace for object 34 when it writes out object 17, then it encrypts it 
again when it writes out object 34.

While debugging I manipulated it to skip the encryption when it was writing out 
object 17 and everything was output correctly.  I'm not sure how 17 is 
connected to 34, but I expect to go through the code and the PDF spec to see 
how everything is connected and processed and come up with a patch.

> Indexed images are sometimes corrupted when encrypting the PDF
> --------------------------------------------------------------
>
>                 Key: PDFBOX-866
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-866
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.8.0-incubator, 1.0.0, 
> 1.1.0, 1.2.0, 1.2.1, 1.3.0
>         Environment: Windows Vista (32-bit)
> Java 1.5
> Head tag of PDFBox
>            Reporter: Adam Nichols
>            Assignee: Adam Nichols
>         Attachments: bitmaptest.pdf, HelpOrderingAppraisal_page1.unc.pdf
>
>
> While PDFBOX-99 did fix this problem with some images, it did not solve the 
> problem in 100% of the cases.  I'll be attaching a file which demonstrates 
> the problem and I plan on fixing this once I figure out what's going awry.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to