/** Creates a JavaScript action. If the JavaScript is smaller than * 50 characters it will be place as a string, otherwise it will * be placed as a compressed stream. * @param code the JavaScript code * @param writer the writer for this action * @return the JavaScript action */ public static PdfAction javaScript(String code, PdfWriter writer) { return javaScript(code, writer, false); }
/** * 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; }
/** * 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; }
/** * A Hide action hides or shows objects. * @param names * @param hide * @return A Hide Action */ public static PdfAction createHide(Object names[], boolean hide) { return createHide(buildArray(names), hide); }
PdfDestination dest = createDestination(c, target); PdfAction action = new PdfAction(); if (!"".equals(handler.getAttributeValue(elem, "onclick"))) { action = PdfAction.javaScript(handler.getAttributeValue(elem, "onclick"), _writer); } else { action.put(PdfName.S, PdfName.GOTO); action.put(PdfName.D, dest); PdfAction action = new PdfAction(uri);
/** 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); }
/** Add a chained action. * @param na the next action */ public void next(PdfAction na) { PdfObject nextAction = get(PdfName.NEXT); if (nextAction == null) put(PdfName.NEXT, na); else if (nextAction.isDictionary()) { PdfArray array = new PdfArray(nextAction); array.add(na); put(PdfName.NEXT, array); } else { ((PdfArray)nextAction).add(na); } }
/** * A Hide action hides or shows an annotation. * @param annot * @param hide * @return A Hide Action */ public static PdfAction createHide(PdfAnnotation annot, boolean hide) { return createHide(annot.getIndirectReference(), hide); }
void addJavaScript(PdfAction js) { if (js.get(PdfName.JS) == null) throw new RuntimeException("Only JavaScript actions are allowed."); try { documentLevelJS.put(SIXTEEN_DIGITS.format(jsCounter++), writer.addToBody(js).getIndirectReference()); } catch (IOException e) { throw new ExceptionConverter(e); } } void addJavaScript(String name, PdfAction js) {
/** * @param name * @param caption * @param value * @param url * @param font * @param fontSize * @param llx * @param lly * @param urx * @param ury * @return a PdfFormField */ public PdfFormField addHtmlPostButton(String name, String caption, String value, String url, BaseFont font, float fontSize, float llx, float lly, float urx, float ury) { PdfAction action = PdfAction.createSubmitForm(url, null, PdfAction.SUBMIT_HTML_FORMAT); PdfFormField button = new PdfFormField(writer, llx, lly, urx, ury, action); setButtonParams(button, PdfFormField.FF_PUSHBUTTON, name, value); drawButton(button, caption, font, fontSize, llx, lly, urx, ury); addFormField(button); return button; }
/** * @param name * @param caption * @param value * @param font * @param fontSize * @param llx * @param lly * @param urx * @param ury * @return a PdfFormField */ public PdfFormField addResetButton(String name, String caption, String value, BaseFont font, float fontSize, float llx, float lly, float urx, float ury) { PdfAction action = PdfAction.createResetForm(null, 0); PdfFormField button = new PdfFormField(writer, llx, lly, urx, ury, action); setButtonParams(button, PdfFormField.FF_PUSHBUTTON, name, value); drawButton(button, caption, font, fontSize, llx, lly, urx, ury); addFormField(button); return button; }
PdfDestination dest = createDestination(c, target); PdfAction action = new PdfAction(); if (!"".equals(handler.getAttributeValue(elem, "onclick"))) { action = PdfAction.javaScript(handler.getAttributeValue(elem, "onclick"), _writer); } else { action.put(PdfName.S, PdfName.GOTO); action.put(PdfName.D, dest); PdfAction action = new PdfAction(uri);
/** 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); }
/** Add a chained action. * @param na the next action */ public void next(PdfAction na) { PdfObject nextAction = get(PdfName.NEXT); if (nextAction == null) put(PdfName.NEXT, na); else if (nextAction.isDictionary()) { PdfArray array = new PdfArray(nextAction); array.add(na); put(PdfName.NEXT, array); } else { ((PdfArray)nextAction).add(na); } }
/** * A Hide action hides or shows objects. * @param names * @param hide * @return A Hide Action */ public static PdfAction createHide(Object[] names, boolean hide) { return createHide(buildArray(names), hide); }
/** * A Hide action hides or shows an annotation. * @param name * @param hide * @return A Hide Action */ public static PdfAction createHide(String name, boolean hide) { return createHide(new PdfString(name), hide); }
void addJavaScript(String name, PdfAction js) { if (js.get(PdfName.JS) == null) throw new RuntimeException("Only JavaScript actions are allowed."); try { documentLevelJS.put(name, writer.addToBody(js).getIndirectReference()); } catch (IOException e) { throw new ExceptionConverter(e); } }
/** * @param name * @param caption * @param value * @param url * @param font * @param fontSize * @param llx * @param lly * @param urx * @param ury * @return a PdfFormField */ public PdfFormField addHtmlPostButton(String name, String caption, String value, String url, BaseFont font, float fontSize, float llx, float lly, float urx, float ury) { PdfAction action = PdfAction.createSubmitForm(url, null, PdfAction.SUBMIT_HTML_FORMAT); PdfFormField button = new PdfFormField(writer, llx, lly, urx, ury, action); setButtonParams(button, PdfFormField.FF_PUSHBUTTON, name, value); drawButton(button, caption, font, fontSize, llx, lly, urx, ury); addFormField(button); return button; }