/** Launches an application or a document. * @param application the application to be launched or the document to be opened or printed. * @param parameters (Windows-specific) A parameter string to be passed to the application. * It can be <CODE>null</CODE>. * @param operation (Windows-specific) the operation to perform: "open" - Open a document, * "print" - Print a document. * It can be <CODE>null</CODE>. * @param defaultDir (Windows-specific) the default directory in standard DOS syntax. * It can be <CODE>null</CODE>. * @return a Launch action */ public static PdfAction createLaunch(String application, String parameters, String operation, String defaultDir) { return new PdfAction(application, parameters, operation, defaultDir); }
PdfAnnotation annotation = PdfAnnotation.createLink( writer, rect, PdfAnnotation.HIGHLIGHT_INVERT, new PdfAction("http://itextpdf.com")); writer.addAnnotation(annotation);
class LinkInCell implements PdfPCellEvent { protected String url; public LinkInCell(String url) { this.url = url; } public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) { PdfWriter writer = canvases[0].getPdfWriter(); PdfAction action = new PdfAction(url); PdfAnnotation link = PdfAnnotation.createLink( writer, position, PdfAnnotation.HIGHLIGHT_INVERT, action); writer.addAnnotation(link); } }
/** * Implements a link to another document. * @param filename the filename for the remote document * @param name the name to jump to * @param llx the lower left x corner of the activation area * @param lly the lower left y corner of the activation area * @param urx the upper right x corner of the activation area * @param ury the upper right y corner of the activation area */ void remoteGoto(final String filename, final String name, final float llx, final float lly, final float urx, final float ury) { annotationsImp.addPlainAnnotation(writer.createAnnotation(llx, lly, urx, ury, new PdfAction(filename, name), null)); }
/** * Implements a link to another document. * @param filename the filename for the remote document * @param page the page to jump to * @param llx the lower left x corner of the activation area * @param lly the lower left y corner of the activation area * @param urx the upper right x corner of the activation area * @param ury the upper right y corner of the activation area */ void remoteGoto(final String filename, final int page, final float llx, final float lly, final float urx, final float ury) { addAnnotation(writer.createAnnotation(llx, lly, urx, ury, new PdfAction(filename, page), null)); }
/** * Implements a link to another document. * @param filename the filename for the remote document * @param name the name to jump to * @param llx the lower left x corner of the activation area * @param lly the lower left y corner of the activation area * @param urx the upper right x corner of the activation area * @param ury the upper right y corner of the activation area */ void remoteGoto(final String filename, final String name, final float llx, final float lly, final float urx, final float ury) { annotationsImp.addPlainAnnotation(writer.createAnnotation(llx, lly, urx, ury, new PdfAction(filename, name), null)); }
/** * Implements a link to another document. * @param filename the filename for the remote document * @param page the page to jump to * @param llx the lower left x corner of the activation area * @param lly the lower left y corner of the activation area * @param urx the upper right x corner of the activation area * @param ury the upper right y corner of the activation area */ void remoteGoto(final String filename, final int page, final float llx, final float lly, final float urx, final float ury) { addAnnotation(writer.createAnnotation(llx, lly, urx, ury, new PdfAction(filename, page), null)); }
PdfReader reader = new PdfReader("hello.pdf"); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("hello_link.pdf")); PdfAnnotation link = PdfAnnotation.createLink(stamper.getWriter(), new Rectangle(36, 790, 559, 806), PdfAnnotation.HIGHLIGHT_INVERT, new PdfAction("hello.pdf", 1)); stamper.addAnnotation(link, 1); stamper.close();
/** * Creates an Import field. * @param file * @return A PdfAction */ public static PdfAction createImportData(String file) { PdfAction action = new PdfAction(); action.put(PdfName.S, PdfName.IMPORTDATA); action.put(PdfName.F, new PdfString(file)); return action; }
/** * Sets an anchor for this <CODE>Chunk</CODE>. * * @param url * the <CODE>URL</CODE> to link to * @return this <CODE>Chunk</CODE> */ public Chunk setAnchor(final URL url) { setRole(PdfName.LINK); String urlStr = url.toExternalForm(); setAccessibleAttribute(PdfName.ALT, new PdfString(urlStr)); return setAttribute(ACTION, new PdfAction(urlStr)); }
/** * Creates an Import field. * @param file * @return A PdfAction */ public static PdfAction createImportData(String file) { PdfAction action = new PdfAction(); action.put(PdfName.S, PdfName.IMPORTDATA); action.put(PdfName.F, new PdfString(file)); return action; }
/** * A Hide action hides or shows an object. * @param obj object to hide or show * @param hide true is hide, false is show * @return a Hide Action */ static PdfAction createHide(PdfObject obj, boolean hide) { PdfAction action = new PdfAction(); action.put(PdfName.S, PdfName.HIDE); action.put(PdfName.T, obj); if (!hide) action.put(PdfName.H, PdfBoolean.PDFFALSE); return action; }
/** * Sets an anchor for this <CODE>Chunk</CODE>. * * @param url * the <CODE>URL</CODE> to link to * @return this <CODE>Chunk</CODE> */ public Chunk setAnchor(final URL url) { setRole(PdfName.LINK); String urlStr = url.toExternalForm(); setAccessibleAttribute(PdfName.ALT, new PdfString(urlStr)); return setAttribute(ACTION, new PdfAction(urlStr)); }
/** * A Hide action hides or shows an object. * @param obj object to hide or show * @param hide true is hide, false is show * @return a Hide Action */ static PdfAction createHide(PdfObject obj, boolean hide) { PdfAction action = new PdfAction(); action.put(PdfName.S, PdfName.HIDE); action.put(PdfName.T, obj); if (!hide) action.put(PdfName.H, PdfBoolean.PDFFALSE); return action; }
/** * Sets an anchor for this <CODE>Chunk</CODE>. * * @param url * the url to link to * @return this <CODE>Chunk</CODE> */ public Chunk setAnchor(final String url) { setRole(PdfName.LINK); setAccessibleAttribute(PdfName.ALT, new PdfString(url)); return setAttribute(ACTION, new PdfAction(url)); }
/** * Sets an anchor for this <CODE>Chunk</CODE>. * * @param url * the url to link to * @return this <CODE>Chunk</CODE> */ public Chunk setAnchor(final String url) { setRole(PdfName.LINK); setAccessibleAttribute(PdfName.ALT, new PdfString(url)); return setAttribute(ACTION, new PdfAction(url)); }
public static PdfAction gotoRemotePage(String filename, String dest, boolean isName, boolean newWindow) { PdfAction action = new PdfAction(); action.put(PdfName.F, new PdfString(filename)); action.put(PdfName.S, PdfName.GOTOR); if (isName) action.put(PdfName.D, new PdfName(dest)); else action.put(PdfName.D, new PdfString(dest, PdfObject.TEXT_UNICODE)); if (newWindow) action.put(PdfName.NEWWINDOW, PdfBoolean.PDFTRUE); return action; }
/** * Creates a resetform. * @param names the objects to reset * @param flags submit properties * @return A PdfAction */ public static PdfAction createResetForm(Object names[], int flags) { PdfAction action = new PdfAction(); action.put(PdfName.S, PdfName.RESETFORM); if (names != null) action.put(PdfName.FIELDS, buildArray(names)); action.put(PdfName.FLAGS, new PdfNumber(flags)); return action; }
/** * Creates a GoTo action to a named destination. * @param dest the named destination * @param isName if true sets the destination as a name, if false sets it as a String * @return a GoTo action */ public static PdfAction gotoLocalPage(String dest, boolean isName) { PdfAction action = new PdfAction(); action.put(PdfName.S, PdfName.GOTO); if (isName) action.put(PdfName.D, new PdfName(dest)); else action.put(PdfName.D, new PdfString(dest, PdfObject.TEXT_UNICODE)); return action; }
/** 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; }