/** * Creates a GoTo action to an internal page. * * @param page the page to go. First page is 1 * @param dest the destination for the page * @param writer the writer for this action * @return a GoTo action */ public static PdfAction gotoLocalPage(int page, PdfDestination dest, PdfWriter writer) { PdfIndirectReference ref = writer.getPageReference(page); PdfDestination d = new PdfDestination(dest); d.addPage(ref); PdfAction action = new PdfAction(); action.put(PdfName.S, PdfName.GOTO); action.put(PdfName.D, d); return action; }
/** * Returns the PDF representation of this <CODE>PdfOutline</CODE>. * * @param writer the encryption information * @param os * @throws IOException */ public void toPdf(PdfWriter writer, OutputStream os) throws IOException { if (color != null && !color.equals(Color.black)) { put( PdfName.C, new PdfArray( new float[] { color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f })); } int flag = 0; if ((style & Font.BOLD) != 0) flag |= 2; if ((style & Font.ITALIC) != 0) flag |= 1; if (flag != 0) put(PdfName.F, new PdfNumber(flag)); if (parent != null) { put(PdfName.PARENT, parent.indirectReference()); } if (destination != null && destination.hasPage()) { put(PdfName.DEST, destination); } if (action != null) put(PdfName.A, action); if (count != 0) { put(PdfName.COUNT, new PdfNumber(count)); } super.toPdf(writer, os); }
/** * Helper for the constructors. * * @param parent the parent outline * @param title the title for this outline * @param open <CODE>true</CODE> if the children are visible */ void initOutline(PdfOutline parent, String title, boolean open) { this.open = open; this.parent = parent; writer = parent.writer; put(PdfName.TITLE, new PdfString(title, PdfObject.TEXT_UNICODE)); parent.addKid(this); if (destination != null && !destination.hasPage()) // bugfix Finn Bock setDestinationPage(writer.getCurrentPage()); }
/** * Set the page of the <CODE>PdfDestination</CODE>-object. * * @param pageReference indirect reference to the page * @return <CODE>true</CODE> if this page was set as the <CODE>PdfDestination</CODE>-page. */ public boolean setDestinationPage(PdfIndirectReference pageReference) { if (destination == null) { return false; } return destination.addPage(pageReference); }