Hello,
I try AsposePDF to merge multiple PDF files. PDF files are arranged like a tree, and I need to create Bookmarks to represent this tree, that means several levels of child bookmarks pointing on nearly each PDF file.
I first concatenate all PDF files, performance is really nice! During this I stock in memory (array) what I need to create Bookmarks. I want to loop on the array to build my bookmarks but the result is not right. I only see the last bookmark added to the Outlines.
For example, I want to obtain the bookmarks following :
+ France
- Aquitaine
> martin
- Bretagne
> maxime
- Charente
> julien
I use this simplify code:
OutlineItemCollection pdfOutlineAsset = new OutlineItemCollection(monPdf.getOutlines());
pdfOutlineAsset.setTitle("France");
pdfOutlineAsset.setBold(true);
pdfOutlineAsset.setAction(new com.aspose.pdf.GoToAction(monPdf.getPages().get_Item(9)));
OutlineItemCollection pdfOutlineGis = new OutlineItemCollection(monPdf.getOutlines());
pdfOutlineGis.setTitle("Aquitaine");
pdfOutlineGis.setAction(new com.aspose.pdf.GoToAction(monPdf.getPages().get_Item(11)));
OutlineItemCollection pdfOutlineRes = new OutlineItemCollection(monPdf.getOutlines());
pdfOutlineRes.setTitle("martin");
pdfOutlineRes.setItalic(true);
pdfOutlineRes.setAction(new com.aspose.pdf.GoToAction(monPdf.getPages().get_Item(13)));
OutlineItemCollection pdfOutlineGis2 = new OutlineItemCollection(monPdf.getOutlines());
pdfOutlineGis2.setTitle("Bretagne");
pdfOutlineGis2.setAction(new com.aspose.pdf.GoToAction(monPdf.getPages().get_Item(14)));
OutlineItemCollection pdfOutlineRes2 = new OutlineItemCollection(monPdf.getOutlines());
pdfOutlineRes2.setTitle("maxime");
pdfOutlineRes2.setItalic(true);
pdfOutlineRes2.setAction(new com.aspose.pdf.GoToAction(monPdf.getPages().get_Item(16)));
OutlineItemCollection pdfOutlineGis3 = new OutlineItemCollection(monPdf.getOutlines());
pdfOutlineGis3.setTitle("Charente");
pdfOutlineGis3.setAction(new com.aspose.pdf.GoToAction(monPdf.getPages().get_Item(17)));
OutlineItemCollection pdfOutlineRes3 = new OutlineItemCollection(monPdf.getOutlines());
pdfOutlineRes3.setTitle("julien");
pdfOutlineRes3.setItalic(true);
pdfOutlineRes3.setAction(new com.aspose.pdf.GoToAction(monPdf.getPages().get_Item(19)));
pdfOutlineGis.add(pdfOutlineRes);
pdfOutlineGis2.add(pdfOutlineRes2);
pdfOutlineGis3.add(pdfOutlineRes3);
pdfOutlineAsset.add(pdfOutlineGis);
pdfOutlineAsset.add(pdfOutlineGis2);
pdfOutlineAsset.add(pdfOutlineGis3);
monPdf.getOutlines().add(pdfOutlineAsset); //mon pdf is my PDF Document
I obtain this instead of what I expect:
+ France
- Charente
> julien
I dont't understand why I lost elements... Can you explain me please?