Re: VFP and Acrobat

Author: Michael Babcock

Posted: 2001-08-17 at 15:35:03

We invoke Adobe Distiller to create our PDFs at report generation time and

then we post them to our web site for our users to view=2E Here's the procedure

(refer to the pc_Destination=3DFILE section):

PROCEDURE Gen_Report1_3

PARAMETERS pc_RptFile, pc_Destination, pn_NumCopies, pc_FileName

&& This procedure will send the report (via param) to either the screen or

printer (via param)=2E

* pc_RptFile =3D name of =2Efrx

* pc_Destination =3D desired output (Screen or Monitor, Printer, File) *=20=

pn_NumCopies =3D number of loop iterations to print multiple copies (will be 1

for screen!)

* pc_FileName =3D filename output (for PDF output)

* mjb 10-09-00 changed the name of this procedure (added 1_3) because it

stayed resident after this

* exe was done, and another report exe tried to use this paragraph of code

instead

* of the generic gen_report=2Eprg procedure that was included with its exe=2E

* mjb 01-02-01 added DIMENSION statement to fix error in errorlog ("LAPRINTERS

is not an array=2E")

local MyLoop, lnCount, lnNumPrinters, laPrinters, lcCurrentPrinter,

lcPDFPrinter

dimension laPrinters(1)

&& mjb 12-05-00 added code to programatically switch printers instead of

telling user to do it manually

if pc_Destination =3D "File" then

lcCurrentPrinter =3D SET("printer",2)

lnNumPrinters =3D aprinters(laPrinters)

for lnCount =3D 1 to lnNumPrinters

if "DISTILLER" $ upper(laPrinters(lnCount)) then

lcPDFPrinter =3D laPrinters(lnCount)

exit && get out of loop; found printer we're looking for!

endif

endfor

if vartype(lcPDFPrinter) =3D "C" and !empty(lcPDFPrinter) then

set printer to NAME (lcPDFPrinter)

endif

if vartype(oDistiller) <> "O" then && mjb 06-29-01 create only as=20=

necessary

to optimize performance

release oDistiller && get rid of whatever existed

oDistiller =3D createobject("pdfDistiller=2EpdfDistiller=2E1") && Instantiate

Acrobat Distiller

wait clear

endif && instantiate distiller object as necessary

endif

with oFrm=2EcntFileInfo=2ElstFileList

for MyLoop =3D 1 to pn_NumCopies

do case && decide which output

case pc_Destination =3D "Printer"

report form (pc_RptFile) to printer noconsole case pc_Destination =3D=20=

"File"

local JustTheFile && get the filename minus the path

JustTheFile =3D justfname(pc_FileName) &&

substr(pc_FileName,rat("",pc_FileName)+1)

JustTheTime =3D ttoc(datetime(),2)

=2EAddItem(JustTheTime + " " + JustTheFile)

report form (pc_RptFile) noconsole to file (evaluate('"' + pc_FileName +

'"'))

set printer to NAME (lcCurrentPrinter) && mjb 12-05-00

oDistiller=2EFileToPDF((pc_FileName),"","")

wait clear && clear out wait wind if going to file

otherwise

KEYBOARD '{CTRL-F10}' PLAIN && -- Force preview into maximized window =20=

report form (pc_RptFile) to printer noconsole preview

exit && don't loop for preview!!!

endcase && decide which output

endfor

endwith

ENDPROC && Gen_Report1_3

HTH,

Michael J=2E Babcock MCP

KePRO

777 East Park Drive

PO Box 8310

Harrisburg, PA 17105-8310

mbabcock@kepro=2Eorg

>>> "ed@leafe=2Ecom" 08/17/01 03:03PM >>>

Hey guys,

Any of you have any experience creating documents in VFP? We're currently

serving up web pages for users to print, but we'd like to incorporate Acrobat

into the site to be able to send the users PDFs instead=2E

©2001 Michael Babcock