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/11/03 18:56:34 UTC

[jira] [Comment Edited] (PDFBOX-2470) Exception in PDDocument.addSignature(PDSignature sigObject, SignatureInterface signatureInterface, SignatureOptions options))

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

John Hewson edited comment on PDFBOX-2470 at 11/3/14 5:56 PM:
--------------------------------------------------------------

{code}
((COSObject) item).getObject();
{code}

There's no need to do COSObject dereferencing manually, just call getDictionaryObject() instead of getItem().

P.S. We should probably change those comments to English.


was (Author: jahewson):
{code}
((COSObject) item).getObject();
{code}

There's no need to do COSObject dereferencing manually, just call getDictionaryObject() instead of getItem().

P.S. We should probably change those comments in to English.

> Exception in PDDocument.addSignature(PDSignature sigObject, SignatureInterface signatureInterface, SignatureOptions options))
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: PDFBOX-2470
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2470
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 1.8.7
>            Reporter: Huynh
>              Labels: patch
>         Attachments: fichedescriptiveformulaire_8954_signed.pdf
>
>
> Hi
> I have made the following modifications to avoid ClassCastException or NullPointerException in addSignature(PDSignature sigObject, SignatureInterface signatureInterface, SignatureOptions options) :
> {code}
>                         // Appearance Dictionary auslesen und setzen
>                         // MOD_CS
>                         // PDAppearanceDictionary ap = 
>                         //        new PDAppearanceDictionary((COSDictionary)cosBaseDict.getItem(COSName.AP));
>                         // ap.getDictionary().setDirect(true);
>                         // signatureField.getWidget().setAppearance(ap);
>                         COSBase item = cosBaseDict.getItem(COSName.AP);
>                         if (item instanceof COSObject) {
>                         	item = ((COSObject) item).getObject();
>                         }
>                     	if (item instanceof COSDictionary) {
>                     		PDAppearanceDictionary ap = new PDAppearanceDictionary((COSDictionary) item);
>                     		ap.getDictionary().setDirect(true);
>                     		signatureField.getWidget().setAppearance(ap);
>                     	}
>                     	
>                         // AcroForm DefaultRessource auslesen und setzen
>                         COSBase dr = cosBaseDict.getItem(COSName.DR);
>                         // MOD_CS
>                         if (dr != null) {
> 	                        dr.setDirect(true);
> 	                        dr.setNeedToBeUpdate(true);
> 	                        acroFormDict.setItem(COSName.DR, dr);
>                         }
> {code}
> Regards



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)