Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
PDF Form Viewing, Field Editing and Printing
Message
From
26/10/2004 13:25:59
 
 
To
26/10/2004 11:12:19
General information
Forum:
Visual FoxPro
Category:
Third party products
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00953565
Message ID:
00954604
Views:
39
Found a means to change the value of the formfield and print the pdf form all in memory so no license issues...
*--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.Exit
Step 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
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform