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

importPage destroys annotations

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.1 PDFBox, 4.0.0
    • 3.0.2 PDFBox, 4.0.0
    • Writing
    • None

    Description

      (This may or may not be a duplicate of PDFBOX-5752)
      I ran the code by Fabian Zünd from the users mailing list, and used as input 3 pages from the PDF specification that I got by using PDFSplit with PDFBox 2.0.31-SNAPSHOT. In page 2 and 3 of the destination some of the annotations point to the wrong object.

      System.out.println("Generating Document");
      //Generate Empty Document
      PDDocument Document = new PDDocument();
      PDAcroForm Form = new PDAcroForm(Document);
      PDResources Resources = new PDResources();
      Resources.put(COSName.HELV, new PDType1Font(FontName.HELVETICA));
      Document.getDocumentCatalog().setAcroForm(Form);
      Form.setDefaultResources(Resources);
      Form.setDefaultAppearance("/Helv 0 Tf 0 g");
      
      //Templates PDF's
      File dir = new File("c:/users/tilman/downloads");
      File PDFRef1 = new File(dir, "pdf_32000_2008-1.pdf");
      File PDFRef2 = new File(dir, "pdf_32000_2008-2.pdf");
      File PDFRef3 = new File(dir, "pdf_32000_2008-3.pdf");
      
      //Load the Templates
      System.out.println("Loading Template Documents");
      PDDocument PDF1 = Loader.loadPDF(PDFRef1);
      PDDocument PDF2 = Loader.loadPDF(PDFRef2);
      PDDocument PDF3 = Loader.loadPDF(PDFRef3);
      
      //Get the First Page of the Template PDF's
      PDPage PDF1Page = PDF1.getPage(0);
      PDPage PDF2Page = PDF2.getPage(0);
      PDPage PDF3Page = PDF3.getPage(0);
      
      System.out.println("Importing Pages");
      
      //Import all pages
      PDPage PDF1Imported = Document.importPage(PDF1Page);
      PDPage PDF2Imported = Document.importPage(PDF2Page);
      PDPage PDF3Imported = Document.importPage(PDF3Page);
      
      System.out.println("Saving Document");
      File Export = new File(dir, "Export.pdf");
      if (Export.exists())
      {
          Export.delete();
      }
      
      Document.save(Export);
      System.out.println("Done");
      

      Attachments

        1. Export.pdf
          32 kB
          Tilman Hausherr
        2. pdf_32000_2008-1.pdf
          57 kB
          Tilman Hausherr
        3. pdf_32000_2008-2.pdf
          67 kB
          Tilman Hausherr
        4. pdf_32000_2008-3.pdf
          89 kB
          Tilman Hausherr
        5. screenshot-1.png
          106 kB
          Tilman Hausherr

        Issue Links

          Activity

            People

              lehmi Andreas Lehmkühler
              tilman Tilman Hausherr
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: