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]

Reply via email to