Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Free PDF Maker for Visual FoxPro

Usefull Functions & Procedures

Free PDF Maker for Visual FoxPro

by  Mike Gagnon  Posted    (Edited  )
This information was supplied to me by Bob Lee:
A Free Pdf Maker for VisualFox Pro.

PDFMaker is not just another windows PDF print driver designed to allow you to send anything to it . The difference is this program works from inside Visual Fox Pro to allow you to use all your existing fox reports and put them on your fox web server or produce a paperless solution for printed reports.

This program is designed to be run either as a server (with your web server or sand alone for desktop usage.

By following these instructions and you should have a PDF Maker, written in pure VFP code in a matter of minutes.
I
PDF Maker uses GhostScript as its internal processor, don't worry, These simple instructions allow you to install and configure it properly quite quickly. PDF Maker does NOT make use of Redmon or any other Shareware Products.

First Get and Configure the Adobe Driver
Download the Generic postscript driver from adobe.com from here.
http://www.adobe.com/support/downloads/product.jsp?product=pdrv&platform=win#
Go to start printers, (or control panels -printers) and select the newly created printer as your default and right-click to properties sheet of the Generic Adobe postscript driver. Select the advanced tab and select new driver.
From listing of manufactures select HP and the printer name of HP Color laser jet 8500 PS.
Then press apply. This creates the color printer driver which in turn creates .ps files (internally converted into PDF files).

Second Install GhostScript
Then install Ghostscript from here. http://www.ghostscript.com/
During installation just use the normal defaults.
If you selected any other non standard place for the location of Ghostscript (meaning anything other than c:\gs\gs7.04\bin\gswin32exe) the edit the file Locationofgs.ini with the correct full path to gswin32.exe

Third Copy the VFP PDFMaker Files (http://www.1amsoftware.com/vfpps2pdf/ps2pdf.zip)
Copy the following files from the this Zip to a working directory (some fox project directory )
ps2pdf.prg
ps2pdfdif.prg
locationofgs.ini

Edit your your own .prgs with reports changing 1 line of code and adding a new line, to something like this.
report form customer_report noconsole to file psfile.ps
=ps2pdf('psfile.ps')

or something like this
my_outputfile = 'output.ps'
report form customer_report noconsole to file &my_outputfile
=ps2pdf(my_outputfile)

Once ps2pdf finishes a file by name of output.pdf or whatever. Your .PDF is created in a sub directory of the current working directory named pdffiles. You can then in code copy or email the files out. By naming your reports output file name, you know the name of the created PDF File . There is no naming the user has to do.

The file ps2pdfdir is a sample utility program designed to show you one way you can convert 100's of ps files in with one command line.
=ps2pdfdir(ôc:\mypsdirectory\ö)
Will convert all of the ps files in that directory û delete them, and place your newly formed pdf files in your pdffile directory

Credits :
I 'borrowed' parts of this code from the Microsoft Knowledge Base and hand converted the freely available Unix and Linux ps2pdf command files which basically do the same postscript to PDF conversions using GhostScript for Linux and Unix. The Microsoft borrowed code consisted the parts referencing createprocess().

Feel free to copy / modify any of this code. Its just my part keeping GNU alive.


Bob Lee
WWW.1amsoftware.com
bobl@1amsoftware.com
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top