PdfOutline implements Serializable { public List<PdfOutline> getAllChildren() { return children; } PdfOutline(String title, PdfDictionary content, PdfDocument pdfDocument);   PdfOutline(String title, PdfDictionary content, PdfOutline parent);   PdfOutline(PdfDocument doc); String getTitle(); void setTitle(String title); void setColor(Color color); void setStyle(int style); PdfDictionary getContent(); List<PdfOutline> getAllChildren(); PdfOutline getParent(); PdfDestination getDestination(); void addDestination(PdfDestination destination); void addAction(PdfAction action); void setOpen(boolean open); PdfOutline addOutline(String title, int position); PdfOutline addOutline(String title); PdfOutline addOutline(PdfOutline outline); void removeOutline(); static int FLAG_ITALIC; static int FLAG_BOLD; }
@Test @LogMessages(messages = { @LogMessage(messageTemplate = LogMessageConstant.SOURCE_DOCUMENT_HAS_ACROFORM_DICTIONARY) }) public void copyPagesWithOutlines() throws IOException { PdfReader reader = new PdfReader(sourceFolder + "iphone_user_guide.pdf"); PdfWriter writer = new PdfWriter(destinationFolder + "copyPagesWithOutlines01.pdf"); PdfDocument pdfDoc = new PdfDocument(reader); PdfDocument pdfDoc1 = new PdfDocument(writer); List<Integer> pages = new ArrayList<>(); pages.add(1); pages.add(2); pages.add(3); pages.add(5); pages.add(52); pages.add(102); pdfDoc1.initializeOutlines(); pdfDoc.copyPagesTo(pages, pdfDoc1); pdfDoc.close(); Assert.assertEquals(6, pdfDoc1.getNumberOfPages()); Assert.assertEquals(4, pdfDoc1.getOutlines(false).getAllChildren().get(0).getAllChildren().size()); pdfDoc1.close(); }
@Test public void testReinitializingOutlines() throws IOException { String input = sourceFolder + "outlineTree.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfReader(input)); PdfOutline root = pdfDocument.getOutlines(false); Assert.assertEquals(4, root.getAllChildren().size()); pdfDocument.getCatalog().getPdfObject().remove(PdfName.Outlines); root = pdfDocument.getOutlines(true); Assert.assertNull(root); pdfDocument.close(); }