Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-2470

Exception in PDDocument.addSignature(PDSignature sigObject, SignatureInterface signatureInterface, SignatureOptions options))

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.7, 1.8.8, 2.0.0
    • Fix Version/s: 1.8.8, 2.0.0
    • Component/s: PDModel
    • Labels:

      Description

      Hi
      I have made the following modifications to avoid ClassCastException or NullPointerException in addSignature(PDSignature sigObject, SignatureInterface signatureInterface, SignatureOptions options) :

                              // read and set Appearance Dictionary
                              // 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);
                          	}
                          	
                              // read and set AcroForm DefaultRessource 
                              COSBase dr = cosBaseDict.getItem(COSName.DR);
                              // MOD_CS
                              if (dr != null) {
      	                        dr.setDirect(true);
      	                        dr.setNeedToBeUpdate(true);
      	                        acroFormDict.setItem(COSName.DR, dr);
                              }
      

      Regards

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              lhuynh Huynh
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: