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

Import XFDF stamp annotation has malformed appearance

    XMLWordPrintableJSON

Details

    Description

      As reported by k.keggenhoff in the user mailing list, when using code like below one gets warnings and the result file doesn't open properly on Adobe Reader.

      Mär 01, 2019 9:35:12 AM org.apache.pdfbox.pdmodel.fdf.FDFAnnotationStamp parseDictElement
      WARNUNG: Group => NOT handling child element: BOOL
      Mär 01, 2019 9:35:12 AM org.apache.pdfbox.pdmodel.fdf.FDFAnnotationStamp parseDictElement
      WARNUNG: Group => NOT handling child element: BOOL
      Mär 01, 2019 9:35:12 AM org.apache.pdfbox.pdmodel.fdf.FDFAnnotationStamp parseDictElement
      WARNUNG: GS0 => NOT handling child element: BOOL
      Mär 01, 2019 9:35:12 AM org.apache.pdfbox.pdmodel.fdf.FDFAnnotationStamp parseDictElement
      WARNUNG: GS0 => NOT handling child element: FIXED
      Mär 01, 2019 9:35:12 AM org.apache.pdfbox.pdmodel.fdf.FDFAnnotationStamp parseDictElement
      WARNUNG: GS0 => NOT handling child element: FIXED
      Mär 01, 2019 9:35:12 AM org.apache.pdfbox.pdmodel.fdf.FDFAnnotationStamp parseDictElement
      WARNUNG: GS1 => NOT handling child element: BOOL
      Mär 01, 2019 9:35:12 AM org.apache.pdfbox.pdmodel.fdf.FDFAnnotationStamp parseDictElement
      WARNUNG: GS1 => NOT handling child element: INT
      Mär 01, 2019 9:35:12 AM org.apache.pdfbox.pdmodel.fdf.FDFAnnotationStamp parseDictElement
      WARNUNG: GS1 => NOT handling child element: INT
      Mär 01, 2019 9:35:12 AM org.apache.pdfbox.pdmodel.fdf.FDFAnnotationStamp parseDictElement
      WARNUNG: P0 => NOT handling child element: ARRAY
      Mär 01, 2019 9:35:12 AM org.apache.pdfbox.pdmodel.fdf.FDFAnnotationStamp parseDictElement
      WARNUNG: P0 => NOT handling child element: INT
      Mär 01, 2019 9:35:12 AM org.apache.pdfbox.pdmodel.fdf.FDFAnnotationStamp parseDictElement
      WARNUNG: Shading => NOT handling child element: ARRAY
      Mär 01, 2019 9:35:12 AM org.apache.pdfbox.pdmodel.fdf.FDFAnnotationStamp parseDictElement
      WARNUNG: Shading => NOT handling child element: ARRAY
      Mär 01, 2019 9:35:12 AM org.apache.pdfbox.pdmodel.fdf.FDFAnnotationStamp parseDictElement
      WARNUNG: Function => NOT handling child element: ARRAY
      Mär 01, 2019 9:35:12 AM org.apache.pdfbox.pdmodel.fdf.FDFAnnotationStamp parseDictElement
      WARNUNG: Function => NOT handling child element: ARRAY
      Mär 01, 2019 9:35:12 AM org.apache.pdfbox.pdmodel.fdf.FDFAnnotationStamp parseDictElement
      WARNUNG: Function => NOT handling child element: ARRAY
      Mär 01, 2019 9:35:12 AM org.apache.pdfbox.pdmodel.fdf.FDFAnnotationStamp parseDictElement
      WARNUNG: Function => NOT handling child element: INT
      Mär 01, 2019 9:35:12 AM org.apache.pdfbox.pdmodel.fdf.FDFAnnotationStamp parseDictElement
      WARNUNG: Function => NOT handling child element: ARRAY
      Mär 01, 2019 9:35:12 AM org.apache.pdfbox.pdmodel.fdf.FDFAnnotationStamp parseDictElement
      WARNUNG: Shading => NOT handling child element: INT
      Mär 01, 2019 9:35:12 AM org.apache.pdfbox.pdmodel.fdf.FDFAnnotationStamp parseStreamElement
      WARNUNG: N => Not handling element DATA encoding: ASCII
                  File pdfFile = new File("lorem_1.pdf");
      
                  System.out.println("Load pdf into PDDocument: " + pdfFile);
                  doc = PDDocument.load(pdfFile);
                  System.out.println("Loaded pdf\n");
      
                  File xfdfFile = new File("lorem.xfdf");
                  System.out.println("\tLoad xfdf into FDFDocument: " + xfdfFile);
                  fdf = FDFDocument.loadXFDF(xfdfFile);
      
                  // Lookup with annotations exists
                  List<FDFAnnotation> fdfAnnots = fdf.getCatalog().getFDF().getAnnotations();
                  // add each annotation in the xfdf into the document
                  for (FDFAnnotation fdfAnnot : fdfAnnots)
                  {
                      PDPage page = doc.getPage(fdfAnnot.getPage());
                      List<PDAnnotation> pageAnnots = page.getAnnotations();
                      annot = PDAnnotation.createAnnotation(fdfAnnot.getCOSObject());
                      annot.setLocked(true);
                      pageAnnots.add(annot);
                  }
                  System.out.println("\tAdded into PDF");
                  fdf.close();
      
                  doc.save("lorem_stamp_markup.pdf");
      

      My first impression: The shading dictionary in the annotation is incomplete. The code in FDFAnnotationStamp.parseDictElement() is incomplete, possibly also the code in parseArrayElement.

      Attachments

        1. AP.xml
          8 kB
          Tilman Hausherr
        2. bad_stamp-2.0.15.xfdf
          16 kB
          Kai Keggenhoff
        3. lorem_1.pdf
          245 kB
          Tilman Hausherr
        4. lorem_3_merged.pdf
          246 kB
          Tilman Hausherr
        5. lorem_stamp_markup-NEW.pdf
          248 kB
          Tilman Hausherr
        6. lorem.xfdf
          11 kB
          Tilman Hausherr

        Issue Links

          Activity

            People

              tilman Tilman Hausherr
              tilman Tilman Hausherr
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: