10.07.2015 Views

Download - Multivac!

Download - Multivac!

Download - Multivac!

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}p.begin_page_ext(pagewidth, pageheight, "");...String optlist = "action={up " + print_action + "} icon=" + print_icon +" tooltip={Print the document} font=" + button_font;p.create_field(left_x, left_y, right_x, right_y, "print_button", "pushbutton", optlist);Cookbook A full code sample can be found in the Cookbook topic interactive/form_pushbutton.Simple text field. Now we create a text field near the upper right corner of the page.The user will be able to enter the current date in this field. We acquire a font handle andcreate a form field of type textfield which is called date, and has a gray background:textfield_font = p.load_font("Helvetica-Bold", "unicode", "");String optlist = "backgroundcolor={gray 0.8} font=" + textfield_font;p.create_field(left_x, left_y, right_x, right_y, "date", "textfield", optlist);By default the font size is auto, which means that initally the field height is used as thefont size. When the input reaches the end of the field the font size is decreased so thatthe text always fits into the field.Cookbook Full code samples can be found in the Cookbook topics in teractive/form_textfield_layoutand interactive/form_textfield_height.Text field with JavaScript. In order to improve the text form field created above we automaticallyfill it with the current date when the page is opened. First we create an actionof type JavaScript (in Acrobat: Run a JavaScript). The script option in the action’s optionlist defines a JavaScript snippet which displays the current date in the date textfield in the format month-day-year:String optlist ="script={var d = util.printd('mmm dd yyyy', new Date()); ""var date = this.getField('date'); date.value = d;}"show_date = p.create_action("JavaScript", optlist);In the second step we create the page. In the option list we supply the action optionwhich attaches the show_date action created above to the trigger event open (in Acrobat:Page Open):String optlist = "action={open " + show_date + "}";p.begin_page_ext(pagewidth, pageheight, optlist);Finally we create the text field as we did above. It will automatically be filled with thecurrent date whenever the page is opened:textfield_font = p.load_font("Helvetica-Bold", "winansi", "");String optlist = "backgroundcolor={gray 0.8} font=" + textfield_font;p.create_field(left_x, left_y, right_x, right_y, "date", "textfield", optlist);Cookbook A full code sample can be found in the Cookbook topic interactive/form_textfield_fill_with_js.70 Chapter 3: PDFlib Programming

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!