You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "John Hewson (JIRA)" <ji...@apache.org> on 2014/10/10 23:55:34 UTC
[jira] [Updated] (PDFBOX-203) PDFBox merge/encryption problem
[ https://issues.apache.org/jira/browse/PDFBOX-203?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
John Hewson updated PDFBOX-203:
-------------------------------
Affects Version/s: 0.7.2
> PDFBox merge/encryption problem
> -------------------------------
>
> Key: PDFBOX-203
> URL: https://issues.apache.org/jira/browse/PDFBOX-203
> Project: PDFBox
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 0.7.2
> Priority: Minor
>
> [imported from SourceForge]
> http://sourceforge.net/tracker/index.php?group_id=78314&atid=552832&aid=1565880
> Originally submitted by patty_c on 2006-09-26 10:47.
> PDFBox-0.7.2
> Windows XP
> I merge two pdfs and encrypt them. When I decrypt
> the merged pdf and open it in Reader, I
> get "unrecognized token" after scrolling down a few
> pages (using the page forward button in Reader).
> Here are code snippets:
> Merge:
> PDDocument oldPdf = PDDocument.load(existingPDF);
> PDDocument newPdf = PDDocument.load(scannedPDF);
> if (oldPdf.isEncrypted()) {
> oldPdf.decrypt(OWNERPASSWORD);
> }
> if (newPdf.isEncrypted()) {
> newPdf.decrypt(OWNERPASSWORD);
> }
> AppendDoc doc = new AppendDoc();
> doc.appendDocument(oldPdf, newPdf);
> oldPdf.save(resultingPDF.getPath());
> oldPdf.close();
> newPdf.close();
>
> Encrypt:
> PDDocument pdf = PDDocument.load(file);
> PDStandardEncryption encryptionOptions = new
> PDStandardEncryption();
> encryptionOptions.setCanModify(false);
> encryptionOptions.setCanPrint(false);
> encryptionOptions.setCanExtractContent(false);
> pdf.setEncryptionDictionary(encryptionOptions);
> pdf.encrypt(OWNERPASSWORD, USERPASSWORD);
> pdf.save(file.getPath());
> pdf.close();
>
> Decrypt:
> PDDocument pdf = PDDocument.load(file);
> if (pdf.isEncrypted()) {
> pdf.decrypt(OWNERPASSWORD);
> pdf.save(file.getPath());
> pdf.close();
> }
> [attachment on SourceForge]
> http://sourceforge.net/tracker/download.php?group_id=78314&atid=552832&aid=1565880&file_id=195367
> test_encrypted.pdf (application/pdf), 63248 bytes
> merged, encrypted pdf;password=123;unrecognized token when you open in Reader
> [comment on SourceForge]
> Originally sent by ng_aldridge.
> Logged In: YES
> user_id=1111818
> Originator: NO
> Are you able to upload the original documents that you were attempting to merge, or examples that cause the same problem? Also, have you tried the latest pdfbox - there have been some fixes to the parser recently.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)