You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (JIRA)" <ji...@apache.org> on 2017/07/01 03:13:00 UTC
[jira] [Closed] (PDFBOX-3848) Get the exact original PDF that was
signed(without signature fields)
[ https://issues.apache.org/jira/browse/PDFBOX-3848?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tilman Hausherr closed PDFBOX-3848.
-----------------------------------
Resolution: Not A Problem
Closing as the SO post has been answered.
> Get the exact original PDF that was signed(without signature fields)
> --------------------------------------------------------------------
>
> Key: PDFBOX-3848
> URL: https://issues.apache.org/jira/browse/PDFBOX-3848
> Project: PDFBox
> Issue Type: Bug
> Components: AcroForm, Signing
> Affects Versions: 2.0.6
> Reporter: Nikola Radosevic
> Attachments: Example.pdf, Example_signed_final.pdf, Example_signed_orig.pdf, Example_Signed.pdf
>
>
> I am trying to get the original pdf from the signed pdf.
> I am able to remove the signature using doc.getSignatureDictionaries().get(0).getSignedContent(signedPDF);
> However, the signature field stays.
> However, when I try to remove the signature fields using the following code:
> PDDocument pdDoc = PDDocument.load(origPDF);
> PDDocumentCatalog catalog = pdDoc.getDocumentCatalog();
> PDAcroForm form = catalog.getAcroForm();
> List<PDField> acroFormFields = form.getFields();
> for (PDField field: acroFormFields) {
> if (field.getFieldType().equalsIgnoreCase("Sig")) {
> System.out.println("START removing Sign Flags");
> field.setReadOnly(true);
> field.setRequired(false);
> field.setNoExport(true);
>
> System.out.println("END removing Sign Flags");
>
> System.out.println("START flattenning field");
> field.getAcroForm().flatten();
> field.getAcroForm().refreshAppearances();
> System.out.println("END flattenning field");
>
> //field.getAcroForm().refreshAppearances();
> }
> The signature field is removed, but the image that was used for visible signature, somehow, magically appear. (The document that I load here is the one that has signature removed using origPDF = doc.getSignatureDictionaries().get(0).getSignedContent(signedPDF);
> See the attached files:
> Example.pdf (Original file)
> Example_Signed.pdf (Signed File)
> Example_Signed_orig.pdf (after removing the signature)
> Example_Signed_final.pdf (after flattening the Example_Signed_orig.pdf)
> See the stackoverflow post for more details:
> https://stackoverflow.com/questions/44843095/verifying-pdf-signature-in-java-using-bouncy-castle-and-pdfbox
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org