/** * 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 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); }
/** * 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); }
/** 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); }
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);
/** 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 name * @param hide * @return A Hide Action */ public static PdfAction createHide(String name, boolean hide) { return createHide(new PdfString(name), hide); }
void addJavaScript(final PdfAction js) { if (js.get(PdfName.JS) == null) throw new RuntimeException(MessageLocalization.getComposedMessage("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(final String name, final 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; }
/** * Creates a GoToE action to an embedded file. * @param filename the root document of the target (null if the target is in the same document) * @param dest the named destination * @param isName if true sets the destination as a name, if false sets it as a String * @return a GoToE action */ public static PdfAction gotoEmbedded(String filename, PdfTargetDictionary target, String dest, boolean isName, boolean newWindow) { if (isName) return gotoEmbedded(filename, target, new PdfName(dest), newWindow); else return gotoEmbedded(filename, target, new PdfString(dest, PdfObject.TEXT_UNICODE), newWindow); }
/** * @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; }
/** * Creates a screen PdfAnnotation * @param writer * @param rect * @param clipTitle * @param fs * @param mimeType * @param playOnDisplay * @return a screen PdfAnnotation * @throws IOException */ public static PdfAnnotation createScreen(PdfWriter writer, Rectangle rect, String clipTitle, PdfFileSpecification fs, String mimeType, boolean playOnDisplay) throws IOException { PdfAnnotation ann = writer.createAnnotation(rect, PdfName.SCREEN); ann.put (PdfName.F, new PdfNumber(FLAGS_PRINT)); ann.put(PdfName.TYPE, PdfName.ANNOT); ann.setPage(); PdfIndirectReference ref = ann.getIndirectReference(); PdfAction action = PdfAction.rendition(clipTitle,fs,mimeType, ref); PdfIndirectReference actionRef = writer.addToBody(action).getIndirectReference(); // for play on display add trigger event if (playOnDisplay) { PdfDictionary aa = new PdfDictionary(); aa.put(new PdfName("PV"), actionRef); ann.put(PdfName.AA, aa); } ann.put(PdfName.A, actionRef); return ann; }
/** 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 annot * @param hide * @return A Hide Action */ public static PdfAction createHide(PdfAnnotation annot, boolean hide) { return createHide(annot.getIndirectReference(), hide); }
void addJavaScript(final PdfAction js) { if (js.get(PdfName.JS) == null) throw new RuntimeException(MessageLocalization.getComposedMessage("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(final String name, final PdfAction js) {