List of usage examples for com.lowagie.text.pdf PushbuttonField LAYOUT_LABEL_ONLY
int LAYOUT_LABEL_ONLY
To view the source code for com.lowagie.text.pdf PushbuttonField LAYOUT_LABEL_ONLY.
Click Source Link
From source file:classroom.newspaper_b.Newspaper10.java
public static void main(String[] args) { try {/*from w w w.j av a 2s.com*/ PdfReader reader = new PdfReader(NEWSPAPER); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(RESULT)); PushbuttonField button; Rectangle rect; rect = new Rectangle(100, 980, 700, 1000); button = new PushbuttonField(stamper.getWriter(), rect, "click"); button.setBackgroundColor(Color.ORANGE); button.setText("Click here to close window"); button.setLayout(PushbuttonField.LAYOUT_LABEL_ONLY); button.setAlignment(Element.ALIGN_RIGHT); PdfFormField menubar = button.getField(); String js = "var f1 = getField('click'); f1.display = display.hidden;" + "var f2 = getField('advertisement'); f2.display = display.hidden;"; menubar.setAction(PdfAction.javaScript(js, stamper.getWriter())); stamper.addAnnotation(menubar, 1); rect = new Rectangle(100, 500, 700, 980); button = new PushbuttonField(stamper.getWriter(), rect, "advertisement"); button.setBackgroundColor(Color.WHITE); button.setBorderColor(Color.ORANGE); button.setImage(Image.getInstance(IMG)); button.setText("Buy the book iText in Action"); button.setLayout(PushbuttonField.LAYOUT_LABEL_TOP_ICON_BOTTOM); PdfFormField advertisement = button.getField(); advertisement.setAction(new PdfAction("http://www.1t3xt.com/docs/book.php")); stamper.addAnnotation(advertisement, 1); stamper.close(); } catch (IOException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } }
From source file:questions.javascript.TriggerMenuButtons.java
public static final void main(String[] args) { Document document = new Document(); try {// www . j av a2 s . c om PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT)); document.open(); document.add(new Paragraph("Triggering Menu Items")); PushbuttonField saveAs = new PushbuttonField(writer, new Rectangle(40, 760, 100, 780), "Save"); saveAs.setBorderColor(Color.BLACK); saveAs.setText("Save"); saveAs.setTextColor(Color.RED); saveAs.setLayout(PushbuttonField.LAYOUT_LABEL_ONLY); PdfFormField saveAsButton = saveAs.getField(); saveAsButton.setAction(PdfAction.javaScript("app.execMenuItem('SaveAs')", writer)); writer.addAnnotation(saveAsButton); PushbuttonField mail = new PushbuttonField(writer, new Rectangle(120, 760, 180, 780), "Mail"); mail.setBorderColor(Color.BLACK); mail.setText("Mail"); mail.setTextColor(Color.RED); mail.setLayout(PushbuttonField.LAYOUT_LABEL_ONLY); PdfFormField mailButton = mail.getField(); mailButton.setAction(PdfAction.javaScript("app.execMenuItem('AcroSendMail:SendMail')", writer)); writer.addAnnotation(mailButton); } catch (IOException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } document.close(); }