[ 
https://issues.apache.org/jira/browse/PDFBOX-5775?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tilman Hausherr updated PDFBOX-5775:
------------------------------------
    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.
 !screenshot-1.png! 
{code:java}
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");
{code}

  was:
(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.
{code:java}
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");
{code}


> importPage destroys annotations
> -------------------------------
>
>                 Key: PDFBOX-5775
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5775
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 3.0.1 PDFBox, 4.0.0
>            Reporter: Tilman Hausherr
>            Priority: Major
>         Attachments: Export.pdf, pdf_32000_2008-1.pdf, pdf_32000_2008-2.pdf, 
> pdf_32000_2008-3.pdf, screenshot-1.png
>
>
> (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.
>  !screenshot-1.png! 
> {code:java}
> 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");
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to