Examples

Examples on creating PDF documents

The following example creates a PDF document, and adds text, DataWindow, .rtf file content, and watermark into the document.

PDFdocument lpdf_doc
PDFpage lpdf_page
PDFtext lpdf_text

lpdf_doc = create PDFdocument
lpdf_page = create PDFpage
lpdf_text = create PDFtext

long ll_return

lpdf_text.content = "Gets or sets the content of the object. "
lpdf_text.textcolor.rgb = rgb(255,0,0)
lpdf_page.addcontent( lpdf_text)
ll_return  = lpdf_page.importcontent( "import\noannots.pdf", 2, 10, 50, 500, 700)
ll_return  = lpdf_doc.addpage( lpdf_page)

lpdf_doc.importdatawindow( dw_1)
lpdf_doc.importpdf( "D:\import\noannots.pdf",1,1,4)

rte_1.insertdocument( "TXdemo.rtf", false,FileTypeRichText!)
ll_return  = lpdf_doc.importrichtextedit( rte_1)

lpdf_doc.watermark.image.filename="D:\import\image1\image.png"
lpdf_doc.watermark.opacity = 50
lpdf_doc.watermark.rotate = 45

ll_return = lpdf_doc.save( "D:\save\pdf_dw_WaterMark.pdf")

The following example creates a PDF document, adds chapters, links and images, and then sets a table of contents for the document.

PDFdocument lpdf_doc
PDFpage lpdf_page,lpdf_page2,lpdf_page3
PDFtext lpdf_text,lpdf_title,lpdf_title1,lpdf_chapter,lpdf_textclone,lpdf_seartext
PDFrichtext lpdf_rtext

PDFimage lpdf_image,lpdf_wrapimage
PDFtableofContents lpdf_toc,lpdf_toc1
PDFtableofContentsitem lpdf_tocitem
PDFtextblock lpdf_block

long ll_return,ll_count
string ls_text

lpdf_doc = Create PDFdocument
lpdf_page = Create PDFpage
lpdf_page2 = Create PDFpage
lpdf_page3 = Create PDFpage
lpdf_text  = Create PDFtext
lpdf_title  = Create PDFtext
lpdf_chapter = Create PDFtext
lpdf_rtext = Create PDFrichtext

lpdf_image = Create PDFimage
lpdf_wrapimage = Create PDFimage
lpdf_toc = Create PDFtableofContents


lpdf_title.content = "TableOfContent"
lpdf_title.font.fontsize = 36
lpdf_title.x = lpdf_page.getwidth( )/2 -lpdf_title.width/2

lpdf_toc.setstyle( PDFTableOfContentsStyle_Classic!)
lpdf_toc.setrightmargin( 100)
lpdf_toc.setleftmargin( 100)
lpdf_toc.settopmargin( 50)
lpdf_toc.settitle( lpdf_title)

lpdf_chapter.content = "Chapter1"
lpdf_tocitem = lpdf_toc.additem( lpdf_chapter)

//PDFtext
lpdf_textclone = lpdf_chapter.clone( )
lpdf_textclone.content = "Chapter1_PDFtext"
lpdf_tocitem.additem( lpdf_textclone)

lpdf_page.addcontent( lpdf_chapter)
lpdf_page.addcontent( lpdf_textclone)

lpdf_text.name = "textname"
lpdf_text.content = "I am PDFtext Content"
//Sets a link that goes to the google translate page
ll_return = lpdf_text.setlinkaddress( "https://translate.google.com/")

lpdf_text.textcolor.rgb =rgb(255,0,0)
lpdf_text.font.bold = true
lpdf_text.font.italic = true
lpdf_page.addcontent( lpdf_text)
//Imports the first PDF page
lpdf_page.importcontent( "import\noannots.pdf", 1, 10, 50, 550, 600)

//PDFimage
lpdf_textclone = lpdf_textclone.clone( )
lpdf_textclone.content = "Chapter1_PDFimage"

lpdf_tocitem.additem( lpdf_textclone)

lpdf_image.filename = "import\image1\image.png"
lpdf_image.y= lpdf_textclone.y + 10
//Sets the image transparency
lpdf_image.transparency = 50
//Links the lpdf_image object to lpdf_text
lpdf_image.linktoobject( lpdf_text)
lpdf_page2.addcontent( lpdf_textclone)
lpdf_page2.addcontent( lpdf_image)

//PDFrichtext
lpdf_textclone = lpdf_textclone.clone( )
lpdf_textclone.content = "Chapter1_PDFrichtext"
lpdf_tocitem.additem( lpdf_textclone)

lpdf_rtext.y = lpdf_textclone.y + 10
lpdf_rtext.width = lpdf_page.getwidth( )
ls_text = "The PDFDocument object allows to import data from a DataWindow object, a DataWindowChild object or a DataStore object, or an existing PDF document to a new PDF document and save the document."
lpdf_block = lpdf_rtext.addtextblock( ls_text)
lpdf_block.textcolor.rgb = rgb(0,0,255)
lpdf_block.layout.firstlineindent = 10
lpdf_block.layout.linespacing = 500
lpdf_block.layout.charspacing =10

//Adds image
lpdf_wrapimage.filename = "import\image1\image2.png"
lpdf_wrapimage.setposition( 40, 10)
lpdf_page3.addcontent( lpdf_wrapimage)
lpdf_rtext.wrapimage( lpdf_wrapimage)
lpdf_page3.addcontent(lpdf_textclone )
lpdf_page3.addcontent(lpdf_rtext )

lpdf_doc.addpage( lpdf_page)
lpdf_doc.addpage( lpdf_page2)
lpdf_doc.addpage( lpdf_page3)

//Gets the count of the level 1 items in the TOC
ll_count = lpdf_toc.getitemcount( )

//Gets the count of the level 2 items in the TOC
ll_count = lpdf_tocitem.getitemcount( )

lpdf_doc.settableofcontents( lpdf_toc)
//Gets the PDFTableOfContents object
lpdf_toc1 = lpdf_doc.gettableofcontents( )
//Gets the title
lpdf_title1 = lpdf_toc1.gettitle( )
ls_text = lpdf_title1.content

//Adds text type watermark
lpdf_doc.watermark.text.content = "WaterMark Test"
lpdf_doc.watermark.text.font.fontsize = 36
lpdf_doc.watermark.text.textcolor.rgb = rgb(0,255,0)
lpdf_doc.watermark.rotate = 45
lpdf_doc.watermark.opacity = 50

//Imports a DataWindow at the end of page 3
ll_return = lpdf_doc.importdatawindow( dw_1,3)
//Counts the pages in lpdf_doc
ll_count = lpdf_doc.getpagecount( )

//Search for PDFText having name = textname
if lpdf_doc.searchobject( "textname").typeof( )=pdftext! then
lpdf_seartext = lpdf_doc.searchobject( "textname")
//Gets the content in the object
ls_text = lpdf_seartext.content
messagebox("searchobject",ls_text)
//Modifies the content
lpdf_seartext.content = lpdf_seartext.content+ "123" 
else
end if

ll_return = lpdf_doc.save( "D:\save\test1.pdf")

The following example creates a PDF document, sets its properties and security, and adds an attachment to it.

PDFdocument lpdf_doc
PDFpage lpdf_page
PDFtext lpdf_text

lpdf_doc = create PDFdocument
lpdf_page = create PDFpage
lpdf_text = create PDFtext

DataStore lds_1
lds_1 = Create DataStore
lds_1.dataobject = "d_dept"
lds_1.settransobject(sqlca)
lds_1.retrieve()

long ll_return

//Sets the document properties
lpdf_doc.properties.author = "tester"
lpdf_doc.properties.subject = "Test subject"
//Sets the document security
lpdf_doc.security.allowcopy = true
lpdf_doc.security.masterpassword = "builder123"
lpdf_doc.security.userpassword = "builder123"

lpdf_text.content = "Gets or sets the content of the object. "
lpdf_text.textcolor.rgb = rgb(255,0,0)
lpdf_page.addcontent( lpdf_text)
ll_return = lpdf_page.importcontent( "import\noannots.pdf", 2, 10, 50, 500, 700)
lpdf_doc.addpage( lpdf_page)

lpdf_doc.importdatawindow(lds_1)
lpdf_doc.importpdf( "D:\import\noannots.pdf",1,1,4)

//Adds attachment
lpdf_doc.attachment.addfile( "D:\import\image1\image.png")

ll_return = lpdf_doc.save( "D:\save\pdf_dw_attachment.pdf")

Examples on the PDFAttachment object

The following example adds attachments into a PDF document, and then manages the attachments.

long ll_return,ll_count
PDFdocument lpdf_doc
PDFpage lpdf_page
PDFattachment lpdf_attach
lpdf_doc = create PDFdocument
lpdf_page = create PDFpage

lpdf_attach = create PDFattachment
//Add file
ll_return =lpdf_attach.addfile( "D:\image\image.png")
//Add files in the specified folder,true means recursively get the files in the sub folders as well
 lpdf_attach.addfolder ( "D:\image",true)
lpdf_doc.attachment = lpdf_attach 
 //Get the count of attachments
ll_count = lpdf_attach.getcount( )
//Remove all attachments
ll_return = lpdf_attach.removeall( )
lpdf_doc.addpage( lpdf_page)
lpdf_doc.save( "D:\save\pdfattachment_addfile.pdf")

Examples on the PDFDocExtractor object

The following example uses the PDFDocExtractor to open the PDF file "extract.pdf" and extract its content.

PDFdocument lpdf_doc
PDFpage lpdf_page
long ll_open,index
double ld_width,ld_height

PDFDocExtractor lpdf_docExt
lpdf_docExt = create PDFDocExtractor
lpdf_doc = create PDFdocument
lpdf_page = create PDFpage

ll_open = lpdf_docExt.open("extract.pdf" )
//Extract all attachments and save in the specified folder. Create the folder if it does not exist
lpdf_docExt.extractallattachments("file" )
//Get the height and width of the first page
lpdf_docExt.getpagesize( 1,ld_width,ld_height )

messagebox("Get the page size of the specified page:","width="+string(ld_width)+",height="+string(ld_height))

lpdf_docExt.close()

lpdf_page.importcontent( "extract.pdf", 1, 10, 10, ld_width, ld_height)

lpdf_doc.addpage( lpdf_page)
lpdf_doc.save( "D:\save\getPagesize.pdf")

The following example uses the PDFDocExtractor to check the compatible standards of PDF files before merging them.

pdfdocument lpdf_doc
PDFdocextractor lpdf_extract

lpdf_extract = create PDFdocextractor
lpdf_doc = create PDFdocument

string ls_pdffile[]
int li_count,li_i,li_standardIndex
long ll_return
PDFstandard lpdf_standard[],lpdf_outPutPDFFileStandard[]

//The relative path to the PDF files
ls_pdffile = {"import\standard_1a.pdf","import\standard_1b.pdf","import\standard_3a.pdf","import\standard_3b.pdf","import\standard_3u.pdf"}

li_count = upperbound(ls_pdffile)
li_standardIndex = 1
//Get the standards of the PDF files to be merged
for li_i = 1 to li_count step 1
 lpdf_extract.open( ls_pdffile[li_i])
 lpdf_standard[li_standardIndex] = lpdf_extract.getstandard( )
 li_standardIndex++
 lpdf_extract.close( )
next
lpdf_extract.getcompatiblestandards( lpdf_standard, lpdf_outPutPDFFileStandard)
if upperbound(lpdf_outPutPDFFileStandard) <=0 then
 messagebox("tips","There is no compatible standards for all the PDF fiels")
end if
messagebox("tip","Count of the compatible standards="+string(upperbound(lpdf_outPutPDFFileStandard)))
//Merge the PDF files
for li_i = 1 to li_count step 1
pdf_doc.importpdf( ls_pdffile[li_i])
next
li_count = upperbound(lpdf_outPutPDFFileStandard)
//Save all the compatible standards
for li_i = 1 to li_count
 ll_return = lpdf_doc.save("D:\save\getcompatiblestandards"+string(li_i)+"_real.pdf",lpdf_outPutPDFFileStandard[li_i])
next

The following example uses the PDFDocExtractor to get the form field objects in the PDF document.

long ll_return,ll_i,ll_count
PDFformfieldtext    lpdf_fieldtext1
PDFformfieldcheckbox  lpdf_checkbox
PDFformfieldcombobox  lpdf_combobox  
PDFformfieldlistbox    lpdf_listbox
PDFformfieldradiobutton lpdf_radio

PDFformfield lpdf_form
//Extract the form information
PDFdocextractor lpdf_docex
lpdf_docex =  create PDFdocextractor

lpdf_docex.open("rt.pdf")
//Count the number of form field objects in the document
ll_count = lpdf_docex.getformfieldcount()
mle_1.text += "Get the number of form field objects. Expect to return 2 lpdf_docex.getformfieldcount()=" +string(ll_count) +"~r~n"

//Iterate to extract the form field objects in the PDF document
for ll_i=1 to ll_count
 lpdf_form = lpdf_docex.getformfield(ll_i)
 if lpdf_form.typeof() = PDFformfieldtext! then
  lpdf_fieldtext1 = lpdf_form
  mle_1.text +="fieldtext object"+string(ll_i)+":currentvalue="+ string(lpdf_fieldtext1.currentvalue)+"~r~n"
 elseif lpdf_form.typeof() = PDFformfieldcheckbox! then
  lpdf_checkbox = lpdf_form
  mle_1.text +="checkbox object"+string(ll_i)+":currentvalue="+ string(lpdf_checkbox.currentvalue)+"~r~n"
 elseif lpdf_form.typeof() = PDFformfieldcombobox! then
  lpdf_combobox = lpdf_form
  mle_1.text +="combobox object"+string(ll_i)+":currentvalue="+ string(lpdf_combobox.currentvalue)+"~r~n"
 elseif lpdf_form.typeof() = PDFformfieldlistbox! then
  lpdf_listbox = lpdf_form
  mle_1.text +="listbox object"+string(ll_i)+":currentvalue="+ string(lpdf_listbox.currentvalue)+"~r~n"	
 elseif lpdf_form.typeof() = PDFformfieldradiobutton! then
  lpdf_radio = lpdf_form
  mle_1.text +="radiobutton object"+string(ll_i)+":currentvalue="+ string(lpdf_radio.currentvalue)+"~r~n"
 end if
next

Examples on the PDFText object

The following example creates a PDF page, adds text to the page, adds a link, and save the page in a PDF document.

PDFdocument lpdf_doc
PDFpage lpdf_page,lpdf_page1
PDFtext lpdf_text,lpdf_textlink,lpdf_textaddress

string ls_address

lpdf_doc = create PDFdocument
lpdf_page = create PDFpage
lpdf_page1 = create PDFpage
lpdf_text = create PDFtext
lpdf_textlink = create PDFtext
lpdf_textaddress = create PDFtext

lpdf_text.backcolor.rgb = rgb(255,0,0)
lpdf_text.textcolor.rgb = rgb(0,255,0)
lpdf_text.font.fontsize = 38
lpdf_text.content = "I am PDFtext text"
lpdf_textlink.content = "jump to me"
//Support PDFtext, PDFmultilinetext, PDFimage, PDFtextblock, and PDFPage
lpdf_text.linktoobject( lpdf_textlink)
lpdf_textaddress.content = "translate.google.com.hk"

//Jump to a website, which can be http, https, ftp, file, and mailto
lpdf_textaddress.setlinkaddress( "https://translate.google.com.hk/?hl=zh-CN&sourceid=cnhp")
//Get the link address
ls_address = lpdf_textaddress.getlinkaddress( )

lpdf_page.addcontent( lpdf_text)
lpdf_page.addcontent( lpdf_textaddress)
lpdf_page1.addcontent( lpdf_textlink)

lpdf_doc.addpage( lpdf_page)
lpdf_doc.addpage( lpdf_page1)
lpdf_doc.save( "save\textlink.pdf")

Examples on the PDFTextBlock object

The following example creates a PDF page, adds a text block with link, and save the page in a PDF document.

PDFdocument lpdf_doc
PDFpage lpdf_page
PDFrichtext lpdf_rtext
PDFtextblock lpdf_block

lpdf_doc = create PDFdocument
lpdf_page = create PDFpage
lpdf_rtext = create PDFrichtext
lpdf_block = create PDFtextblock

lpdf_rtext.width = lpdf_page.getwidth( )
lpdf_block.content = "test localfileaction"
//setlinkaddress. Supported; mailto://, file://, https://, and http://
lpdf_block.setlinkaddress( "https://translate.google.com.hk/?hl=zh-CN&sourceid=cnhp")
lpdf_rtext.addtextblock( lpdf_block)
lpdf_block.getlinkaddress( )
lpdf_page.addcontent( lpdf_rtext)
lpdf_doc.addpage( lpdf_page)
lpdf_doc.save( "D:\block_linkaddress.pdf")

The following example presents more detailed settings of the text block.

PDFdocument lpdf_doc
PDFpage lpdf_page
PDFrichtext lpdf_rtext
PDFtextblock lpdf_block
PDFtext lpdf_text

lpdf_doc = create PDFdocument
lpdf_page = create PDFpage
lpdf_rtext = create PDFrichtext
lpdf_block = create PDFtextblock
lpdf_text = create PDFtext
lpdf_rtext.width = lpdf_page.getwidth( )

lpdf_block.charspacing = 300
lpdf_block.backcolor.rgb = rgb(0,255,0)
lpdf_block.textcolor.rgb = rgb(0,0,255)
lpdf_block.font.fontsize = 36

lpdf_block.layout.alignment = PDFTextAlignCenter!
lpdf_block.content = "pdftextblock linkto  pdftext"
lpdf_text.content = "link to me"

//Link to PDFmultilinetext, PDFimage, PDFtext, or PDFtextblock
lpdf_block.linktoobject( lpdf_text)
lpdf_rtext.addtextblock( lpdf_block)
lpdf_page.addcontent( lpdf_rtext)
lpdf_page.addcontent( lpdf_text)
lpdf_doc.addpage( lpdf_page)
lpdf_doc.save( "D:\ block_linkto.pdf")

Examples on the PDFWatermark object

The following example sets a PDF watermark which is text.

PDFdocument lpdf_doc
PDFpage lpdf_page
PDFwatermark lpdf_water

lpdf_doc = create PDFdocument
lpdf_page = create PDFpage
lpdf_water = create PDFwatermark

lpdf_doc.addpage( lpdf_page)
lpdf_doc.watermark.text.content = "text watermark"
//The fontsize determines the watermark size
lpdf_doc.watermark.text.font.fontsize = 38

lpdf_doc.watermark.opacity = 50
lpdf_doc.watermark.rotate = 45

lpdf_doc.save("D:\ watermark.pdf" )

The following example sets a PDF watermark which is an image.

PDFdocument lpdf_doc
PDFpage lpdf_page
PDFwatermark lpdf_water

lpdf_doc = create PDFdocument
lpdf_page = create PDFpage
lpdf_water = create PDFwatermark

lpdf_doc.addpage( lpdf_page)
lpdf_doc.watermark.image.filename = "D:\image\image.jpg"
lpdf_doc.watermark.opacity = 50
lpdf_doc.watermark.rotate = 45
//The scale setting determines the watermark size
lpdf_doc.watermark.scale = 0.5
lpdf_doc.save("save\watermark_2.pdf" )

Examples on the PDFFormFieldCheckBox object

The following example adds a checkbox to the PDF page.

long ll_return
PDFdocument   lpdf_doc
PDFpage         lpdf_page
PDFtext  lpdf_text
PDFformfieldcheckbox  lpdf_checkbox

lpdf_doc = create PDFdocument
lpdf_page = create PDFpage
lpdf_text = create PDFtext
lpdf_checkbox = create PDFformfieldcheckbox

//bordercolor must be set for the border to display
lpdf_checkbox.bordercolor.rgb = rgb(0,0,0)
lpdf_checkbox.setposition(100, 100)

lpdf_text.content = "checkbox"
lpdf_text.setposition(110+ lpdf_checkbox.width , 100)

//Add checkbox to PDFpage
lpdf_page.addcontent(lpdf_checkbox)

lpdf_page.addcontent(lpdf_text)
lpdf_doc.addpage(lpdf_page)
ll_return = lpdf_doc.save("checkbox.pdf")

Examples on the PDFFormFieldComboBox object

The following example adds a combobox to the PDF page.

long ll_return
string ls_itemtext[]
PDFdocument   lpdf_doc
PDFpage         lpdf_page
PDFtext  lpdf_text
PDFformfieldcombobox  lpdf_combobox

lpdf_doc = create PDFdocument
lpdf_page = create PDFpage
lpdf_text = create PDFtext
lpdf_combobox = create PDFformfieldcombobox

//bordercolor must be set for the border to display
lpdf_combobox.bordercolor.rgb = rgb(0,0,0)
lpdf_combobox.setposition(100, 100)
ls_itemtext = {"item1","item3","item4","item2"}
//Add list
lpdf_combobox.setitemlist(ls_itemtext)
//Add one more item to the list
lpdf_combobox.additem("item5")
//Sort the items
lpdf_combobox.sorted = true

lpdf_text.content = "combobox"
lpdf_text.setposition(110+ lpdf_combobox.width , 100)

//Add combobox to the PDFpage
lpdf_page.addcontent(lpdf_combobox)

lpdf_page.addcontent(lpdf_text)
lpdf_doc.addpage(lpdf_page)
ll_return = lpdf_doc.save("combobox.pdf")

Examples on the PDFFormFieldListBox object

The following example adds a listbox to the PDF page.

long ll_return
string ls_itemtext[]
PDFdocument   lpdf_doc
PDFpage         lpdf_page
PDFtext  lpdf_text
PDFformfieldlistbox  lpdf_listbox

lpdf_doc = create PDFdocument
lpdf_page = create PDFpage
lpdf_text = create PDFtext
lpdf_listbox = create PDFformfieldlistbox

//bordercolor must be set for the border to display
lpdf_listbox.bordercolor.rgb = rgb(0,0,0)
lpdf_listbox.setposition(100, 100)
ls_itemtext = {"item1","item3","item4","item2"}
//Add list
lpdf_listbox.setitemlist(ls_itemtext)
//Add one more item to the list
lpdf_listbox.additem("item5")
//Sort the items
lpdf_listbox.sorted = true

lpdf_text.content = "listbox"
lpdf_text.setposition(110+ lpdf_listbox.width , 100)

//Add listbox to the PDFpage
lpdf_page.addcontent(lpdf_listbox)

lpdf_page.addcontent(lpdf_text)
lpdf_doc.addpage(lpdf_page)
ll_return = lpdf_doc.save("listbox.pdf")

Examples on the PDFFormFieldPushButton object

The following example adds several push buttons to the PDF page and these buttons have different actions.

long ll_return
string ls_itemtext[]
PDFdocument   lpdf_doc
PDFpage         lpdf_page
PDFtext  lpdf_text
PDFformfieldpushbutton  lpdf_pushbutton
PDFformfieldcombobox   lpdf_combobox

PDFactionjavascript    lpdf_javascript
PDFactionnamed     lpdf_named
PDFactionresetform  lpdf_resetform

lpdf_doc = create PDFdocument
lpdf_page = create PDFpage
lpdf_text = create PDFtext
lpdf_pushbutton = create PDFformfieldpushbutton
lpdf_javascript = create PDFactionjavascript
lpdf_named = create PDFactionnamed
lpdf_combobox = create PDFformfieldcombobox

//bordercolor must be set for the border to display
lpdf_pushbutton.bordercolor.rgb = rgb(0,0,0)
lpdf_pushbutton.setposition(100, 100)
lpdf_pushbutton.caption = "PDFactionjavascript"
lpdf_pushbutton.icondown.filename = "pic.png"
lpdf_javascript.script = "app.alert(~"PDFActionJavaScript ~");"
lpdf_pushbutton.addaction(PDFFormFieldEvent_Exit!,lpdf_javascript)
lpdf_text.content = "pushbutton PDFActionJavaScript"
lpdf_text.setposition(110+ lpdf_pushbutton.width , 100)
//Add pushbutton to the PDFpage
lpdf_page.addcontent(lpdf_pushbutton)
lpdf_page.addcontent(lpdf_text)

lpdf_pushbutton = create PDFformfieldpushbutton
lpdf_named.menuname = "SaveAs"
lpdf_pushbutton.bordercolor.rgb = rgb(0,0,0)
lpdf_pushbutton.setposition(100, 150)
lpdf_pushbutton.caption = "SaveAs"
lpdf_pushbutton.addaction(PDFFormFieldEvent_Down!,lpdf_named)
lpdf_text = lpdf_text.clone()
lpdf_text.content = "pushbutton PDFactionnamed"
lpdf_text.setposition(110+ lpdf_pushbutton.width , 150)
//Add pushbutton to the PDFpage
lpdf_page.addcontent(lpdf_pushbutton)
lpdf_page.addcontent(lpdf_text)

lpdf_pushbutton = create PDFformfieldpushbutton
lpdf_resetform= create PDFactionresetform
lpdf_pushbutton.bordercolor.rgb = rgb(0,0,0)
lpdf_pushbutton.setposition(100, 200)
lpdf_pushbutton.caption = "resetform"
//Reset the form
lpdf_pushbutton.addaction(PDFFormFieldEvent_Down!,lpdf_resetform)
//Add pushbutton to the PDFpage
lpdf_page.addcontent(lpdf_pushbutton)

ls_itemtext ={"item1","item2","item3"}
lpdf_combobox.bordercolor.rgb = rgb(0,0,0)
lpdf_combobox.setposition(100, 250)
lpdf_combobox.setitemlist(ls_itemtext)
lpdf_combobox.currentvalue = lpdf_combobox.getitemtext(2)
lpdf_page.addcontent(lpdf_combobox)

lpdf_doc.addpage(lpdf_page)
ll_return = lpdf_doc.save("pushbutton.pdf")

Examples on the PDFFormFieldText object

The following example adds a fieldtext to the PDF page.

long ll_return

PDFdocument   lpdf_doc
PDFpage         lpdf_page
PDFtext  lpdf_text
PDFformfieldtext  lpdf_fieldtext

lpdf_doc = create PDFdocument
lpdf_page = create PDFpage
lpdf_text = create PDFtext
lpdf_fieldtext = create PDFformfieldtext

//bordercolor must be set for the border to display
lpdf_fieldtext.bordercolor.rgb = rgb(0,0,0)
lpdf_fieldtext.setposition(100, 100)
lpdf_fieldtext.charspacing = 2
lpdf_text.content = "PDFformfieldtext"
lpdf_text.setposition(110+ lpdf_fieldtext.width , 100)

//Add fieldtext to the PDFpage
lpdf_page.addcontent(lpdf_fieldtext)
lpdf_page.addcontent(lpdf_text)

lpdf_doc.addpage(lpdf_page)
ll_return = lpdf_doc.save("fieldtext.pdf")

Examples on the PDFFormFieldRadioButton and PDFFormFieldRadioButtonGroup object

The following example adds the radiobutton objects to a group and then add the group to the PDF document.

long ll_return

PDFdocument   lpdf_doc
PDFpage         lpdf_page
PDFtext  lpdf_text
PDFformfieldradiobutton  lpdf_radiobutton
PDFformfieldradiobuttonGroup  lpdf_rbgroup

lpdf_doc = create PDFdocument
lpdf_page = create PDFpage
lpdf_text = create PDFtext
lpdf_radiobutton = create PDFformfieldradiobutton
lpdf_rbgroup = create PDFformfieldradiobuttonGroup

lpdf_rbgroup.tooltip = "tip Yes or No"
//bordercolor must be set for the border to display
lpdf_radiobutton.bordercolor.rgb = rgb(0,0,0)
lpdf_radiobutton.setposition(100, 100)
//Set the button style
lpdf_radiobutton.buttonstyle = PDFFormFieldButtonStyle_Circle!
lpdf_text.content = "Yes"
lpdf_text.setposition(110+ lpdf_radiobutton.width , 100)
//Add radiobutton to the group
lpdf_rbgroup.add(lpdf_radiobutton)
//Add radiobutton to the PDFpage
lpdf_page.addcontent(lpdf_radiobutton)
lpdf_page.addcontent(lpdf_text)

lpdf_radiobutton = create PDFformfieldradiobutton
lpdf_radiobutton.bordercolor.rgb = rgb(0,0,0)
lpdf_radiobutton.setposition(150, 100)
//Set the button style
lpdf_radiobutton.buttonstyle = PDFFormFieldButtonStyle_Circle!
lpdf_text = lpdf_text.clone()
lpdf_text.content = "No"
lpdf_text.setposition(160+ lpdf_radiobutton.width , 100)
//Add radiobutton to the group
ll_return = lpdf_rbgroup.add(lpdf_radiobutton)
//Add radiobutton to the PDFpage
lpdf_page.addcontent(lpdf_radiobutton)
lpdf_page.addcontent(lpdf_text)

//Add group to the doc
lpdf_doc.addformfieldgroup(lpdf_rbgroup)
lpdf_doc.addpage(lpdf_page)
ll_return = lpdf_doc.save("radiobutton.pdf")