PDFBox opens the file fine....

Code:
                PDDocument doc = null;
                
                try {
                        doc = PDDocument.load(pdfIn);
                        PDPage page = null;

                        for (int i = 0; i < doc.getNumberOfPages(); i++) {
                                page = doc.getPage(i);
                                PDPageContentStream canvas = new 
PDPageContentStream(doc, page, PDPageContentStream.AppendMode.APPEND, true, 
true);
                                canvas.saveGraphicsState();
                                canvas.restoreGraphicsState();
                                canvas.close();
                        }
                        bRet = true;
                }
                finally {
                        if (doc != null) {
                                doc.close();
                        }
                }

Output:
0 [Finalizer] DEBUG org.apache.pdfbox.io.ScratchFileBuffer  - ScratchFileBuffer 
not closed!
2 [Finalizer] DEBUG org.apache.pdfbox.io.ScratchFileBuffer  - ScratchFileBuffer 
not closed!
3 [Finalizer] DEBUG org.apache.pdfbox.io.ScratchFileBuffer  - ScratchFileBuffer 
not closed!
3 [Finalizer] DEBUG org.apache.pdfbox.io.ScratchFileBuffer  - ScratchFileBuffer 
not closed!
3 [Finalizer] DEBUG org.apache.pdfbox.io.ScratchFileBuffer  - ScratchFileBuffer 
not closed!
3 [Finalizer] DEBUG org.apache.pdfbox.io.ScratchFileBuffer  - ScratchFileBuffer 
not closed!
4 [Finalizer] DEBUG org.apache.pdfbox.io.ScratchFileBuffer  - ScratchFileBuffer 
not closed!
4 [Finalizer] DEBUG org.apache.pdfbox.io.ScratchFileBuffer  - ScratchFileBuffer 
not closed!
4 [Finalizer] DEBUG org.apache.pdfbox.io.ScratchFileBuffer  - ScratchFileBuffer 
not closed!
5 [Finalizer] DEBUG org.apache.pdfbox.io.ScratchFileBuffer  - ScratchFileBuffer 
not closed!
5 [Finalizer] DEBUG org.apache.pdfbox.io.ScratchFileBuffer  - ScratchFileBuffer 
not closed!
5 [Finalizer] DEBUG org.apache.pdfbox.io.ScratchFileBuffer  - ScratchFileBuffer 
not closed!
5 [Finalizer] DEBUG org.apache.pdfbox.io.ScratchFileBuffer  - ScratchFileBuffer 
not closed!
7 [Finalizer] DEBUG org.apache.pdfbox.io.ScratchFileBuffer  - ScratchFileBuffer 
not closed!


-----Original Message-----
From: Stahle, Patrick [mailto:[email protected]] 
Sent: Wednesday, March 16, 2016 3:45 PM
To: [email protected]
Subject: RE: Strange "Save As" issue with Adobe Reader 11 / DC with PDF being 
encrypted by PDFBox 2 snapshot

Also other applications like PDF Exchange do not exhibit the problem. Most 
likely has something to do with the 3D capabilities of Adobe Reader....

-----Original Message-----
From: Tilman Hausherr [mailto:[email protected]] 
Sent: Wednesday, March 16, 2016 3:38 PM
To: [email protected]
Subject: Re: Strange "Save As" issue with Adobe Reader 11 / DC with PDF being 
encrypted by PDFBox 2 snapshot

Can you reopen the file you saved with PDFBox? If not, please open an issue in 
JIRA and attach your file.

If yes, just upload the file somewhere, I'd like to have a look at the 
encryption dictionaries.

Tilman

Am 16.03.2016 um 20:19 schrieb Stahle, Patrick:
> Hi,
>
> This is not a general problem and only occurs with original PDF generated 
> with 3D content using Anark. The file when loaded seems to have encrypted and 
> loads just find in Adobe Reader, but when we try to do a "Save As" we get the 
> following error:
> "The document could not be saved. There was a problem reading this document 
> 21."
>
> If I do a control click on the "ok" button. I get the following message:
> "This direct object already has a container."
>
> Any ideas what might be causing this problem? We have tried the same thing 
> with iText and it does not experience this problem.
>
> Sample Code that reproduces the problem:
>                                  PDDocument doc = null;
>
>                                  try {
>                                                  doc = PDDocument.load(pdfIn);
>                                                  PDPage page = null;
>                                                  AccessPermission apermission 
> = new AccessPermission();
>                                                  
> apermission.setCanAssembleDocument(false);
>                                                  
> apermission.setCanExtractContent(false);
>                                                  
> apermission.setCanExtractForAccessibility(true);
>                                                  
> apermission.setCanFillInForm(true);
>                                                  
> apermission.setCanModifyAnnotations(true);
>                                                  
> apermission.setCanPrint(true);
>                                                  apermission.setReadOnly();
>                                                  StandardProtectionPolicy spp 
> = new StandardProtectionPolicy(UUID.randomUUID().toString(), "", apermission);
>                                                  doc.protect(spp);
>
>                                                  for (int i = 0; i < 
> doc.getNumberOfPages(); i++) {
>                                                                  page = 
> doc.getPage(i);
>                                                                  
> PDPageContentStream canvas = new PDPageContentStream(doc, page, 
> PDPageContentStream.AppendMode.APPEND, true, true);
>                                                                  
> canvas.saveGraphicsState();
>                                                                  
> canvas.restoreGraphicsState();
>                                                                  
> canvas.close();
>                                                  }
>                                                  doc.save(pdfOut);
>                                                  bRet = true;
>                                  }
>                                  finally {
>                                                  if (doc != null) {
>                                                                  doc.close();
>                                                  }
>                                  }
>
> Thanks,
> Patrick
>
>


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


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


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

Reply via email to