List of usage examples for com.lowagie.text.pdf PdfOutline setOpen
public void setOpen(boolean open)
From source file:com.geek.tutorial.itext.bookmarks.Outline.java
License:Open Source License
public Outline() throws Exception { Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("outline.pdf")); document.open();/*from www. ja v a2 s .co m*/ // Code 1 document.add(new Chunk("Chapter 1").setLocalDestination("1")); document.newPage(); document.add(new Chunk("Chapter 2").setLocalDestination("2")); document.add(new Paragraph(new Chunk("Sub 2.1").setLocalDestination("2.1"))); document.add(new Paragraph(new Chunk("Sub 2.2").setLocalDestination("2.2"))); document.newPage(); document.add(new Chunk("Chapter 3").setLocalDestination("3")); // Code 2 PdfContentByte cb = writer.getDirectContent(); PdfOutline root = cb.getRootOutline(); // Code 3 PdfOutline oline1 = new PdfOutline(root, PdfAction.gotoLocalPage("1", false), "Chapter 1"); PdfOutline oline2 = new PdfOutline(root, PdfAction.gotoLocalPage("2", false), "Chapter 2"); oline2.setOpen(false); PdfOutline oline2_1 = new PdfOutline(oline2, PdfAction.gotoLocalPage("2.1", false), "Sub 2.1"); PdfOutline oline2_2 = new PdfOutline(oline2, PdfAction.gotoLocalPage("2.2", false), "Sub 2.2"); PdfOutline oline3 = new PdfOutline(root, PdfAction.gotoLocalPage("3", false), "Chapter 3"); document.close(); }
From source file:org.areasy.common.doclet.document.Bookmarks.java
License:Open Source License
/** * Creates entries for all the given bookmark entry objects. * If any of them has child nodes, the method calls itself * recursively to process them as well./*w w w .j a v a2 s . c o m*/ * * @param parent The parent PDF outline object. * @param entries The bookmark entries for which to add outline objects. */ private static void createBookmarks(PdfOutline parent, BookmarkEntry[] entries) { if (entries == null) return; for (int i = 0; i < entries.length; i++) { String name = entries[i].getDestinationName(); PdfAction action = null; if (name == null) action = new PdfAction(); else action = PdfAction.gotoLocalPage(name, false); PdfOutline outline = new PdfOutline(parent, action, entries[i].getLabel()); outline.setOpen(false); createBookmarks(outline, entries[i].getChildren()); } }
From source file:webBoltOns.server.reportWriter.JRivetWriter.java
License:Open Source License
/** * <h2><code>fireNewSection</code></h2> * // w ww .j av a 2s . c o m * <p> * Executed by <code>ReportAccumulator</code> when a new section is * detected * </p> * * @param ReportAccumulator ac - Source creating the new section. * @param String newValue - the value of the new section. * */ public void fireNewSection(ReportAccumulator ac, String newValue) { PdfOutline outLine = new PdfOutline(ac.getParentAccumulator().getOutline(), new PdfDestination(PdfDestination.FITH, 50), newValue); outLine.setOpen(false); ac.setOutline(outLine); }