*--This example reqs test.pdf with the following fieldnames (all are case sensitive): * "AGENCY.NAME" * "AGENCY.ADDR1" * "AGENCY.CITYSTZIP" sFieldName = "AGENCY.NAME" sFieldName2 = "AGENCY.ADDR1" sFieldName3 = "AGENCY.CITYSTZIP" sfileName = "C:\acordforms\test\test.pdf" IF !FILE(sFileName) =MESSAGEBOX('Cannot locate: '+sfilename) sFileName=GETFILE('pdf','PDF File:','Open',1,'Please select a pdf file with the formfield AGENCY.ADDR1') IF !FILE(sFileName) =MESSAGEBOX('Cannot locate: '+sfilename) RETURN ENDIF ENDIF AcroExchApp = CREATEOBJECT("AcroExch.App") AcroExchAVDoc = CreateObject("AcroExch.AVDoc") AcroExchAVDoc.Open(sFileName, "") AcroForm = CreateObject("AFormAut.App") AcroFields = AcroForm.Fields *--Get the value of the first field AGENCY.NAME in our test.pdf AcroField = AcroFields.Item(sFieldName) *--Get the value of the 2nd field AGENCY.ADDR1 in our test.pdf AcroField2 = AcroFields.Item(sFieldName2) MESSAGEBOX(PADR(PADL("FORMFIELD AGENCY.NAME value:",40),80)+CHR(13)+AcroField.Value+CHR(13)+CHR(13); +PADR(PADL("FORMFIELD AGENCY.ADDR1 value:",40),80)+CHR(13)+AcroField2.Value,0+64+4096,"Value Retrieved by Automation") IF MESSAGEBOX('Print '+sFileName+'?',1+32+4096,'Send to Printer')=1 AcroExchAVDoc.PrintPages(0, 1, 2, .t., .f.) ENDIF *--Get the value of the citystzip formfield using javascript sJS = "event.value = this.getField("+"'"+sFieldName3+"'"+").value;" sValue = AcroForm.Fields.ExecuteThisJavaScript(sJS) =MESSAGEBOX(PADR(PADL("AGENCY.CITYSTZIP value:",40),80)+CHR(13)+sValue+CHR(13),0+64+4096,"Value Retrieved by JavaScript") *--Change the agency name and addr1 field values on the pdf form Acrofield.value = "New Company Name" Acrofield2.value = "New Street Address" MESSAGEBOX(PADR(PADL("FORMFIELD AGENCY.NAME value:",40),80)+CHR(13)+AcroField.Value+CHR(13)+CHR(13); +PADR(PADL("FORMFIELD AGENCY.ADDR1 value:",40),80)+CHR(13)+AcroField2.Value,0+64+4096,"Value Changed and Retrieved by Automation") IF MESSAGEBOX('Print modified '+sFileName+'?',1+32+4096,'Send to Printer')=1 AcroExchAVDoc.PrintPages(0, 1, 2, .t., .f.) ENDIF AcroExchAVDoc.Close(.T.) AcroExchApp.ExitStep through all fields in a form and change the value if desired:
i = 0 FOR EACH Acrofield IN AcroForm.Fields WITH AcroField i = i + 1 DIMENSION fieldlist(i,2) fieldlist(i,1)=acrofield.name fieldlist(i,2)=acrofield.value *--Change value if desired *acrofield.value = "new value" ENDWITH ENDFOR