|Free/Simple VFP Report To PDF - Print2PDF|
Tuesday, July 23rd, 2002 at 00h24
Here is a free/fast/simple way to create PDF files directly from VFP. This is "black box" code/class that will run a VFP report and output it to a PDF. It will even automatically install any needed components for the user! It's easy to setup and to use! It is very flexible for programmers, easy for end-users, and well documented.
Print2PDF automatically selects the free Adobe Postcript printer driver to create a Postscript file (a temporary file in the VFP temporary path). It then calls the free DLL of Ghostscript to turn that Postscript file into a true PDF file. You can pass in the report name and the output name/path.
This is an fast, free, and elegant solution to PDF generation from VFP.
*** Version 1.1 ***
This update adds the functionality of automatically locating the Ghostscript files. Also, the download now includes Ed Rauh's clsheap.prg.
***Version 1.2 ***
Turned the program into a Class.
Added logic to allow the user to install Postscript on-the-fly.
Added logic to allow the user to install Ghostscript on-the-fly.
Added logic to allow the user to install Adobe Acrobat on-the-fly.
Added the ability to read most setting from the .INI file.
Put logic in the Install() method and .INI file that will allow you to install any other program also.
*** Version 1.3 ***
Added support for printing "color" in pdf.
You can change printer resolution on-the-fly.
Made it callable as a "procedure".
Complete Demo program (including dbf and report).
Included the complete Ghostscript and Adobe Postscript installs.
Corrected some logic bugs, and bugs in the .ini processing.
Added the ability to use "variable" paths for Installs
Added any new properties to .ini file.
++Please be aware that version 1.3 has CHANGED some .ini settings!
*** Version 1.4 ***
Some bug fixes and a timing fix to avoid error message when trying to delete temporary files.
*** Sept. 2003 ***
Fixed broken FTP Link to get this file.
*** Dec. 2006 ***
New FTP Link.
*** August 2008 - Version 1.51 ***
Updated to be more flexible when looking for Ghostscript and added some extra debugging code.
|No||Created by||Created on||Comment|
|1.||Klaus Hentschel||24/07/2002 05:49||Where can I find the ClsHeap.prg? I try the Mailaddress to Ed Rauh (found in the print2pdf.prg) but this one is not correct.|
|2.||Matt Mathai||24/07/2002 08:24||Search for clsheap (in summary $) and download clsheap.zip|
|3.||Klaus Hentschel||24/07/2002 13:50||Thank you. My Fault, why I don't become this idea.|
|4.||Klaus Hentschel||25/07/2002 09:39||Another question.
Is it possible to create colored PDF? When I print to a PDF everything goes Gray.|
|5.||Mike Albert||08/08/2002 10:14||Sweet code, Paul. It is possible to get color text or shapes but I can't seem to get color images. In foxpro, you can set the color of each item on the form. The key (I think) is using a color printer's PS driver. I'm using the HP Color LaserJet PS (with port FILE under the DETAILS tab) that is included in windows. The only thing I couldn't get color was the image. If anyone figures that out, email me at firstname.lastname@example.org with subject "universal thread" otherwise I won't see it with all the junk mail I get. Thanks again, Paul, this was just what I needed.|
|6.||Paul James||12/08/2002 10:37||Please check out the newest version (1.3). Color printing is now enabled, also several fixes, updates, etc. Thanks - Paul|
|7.||Bob Lee||15/08/2002 11:11||Nice update Works first time,
|8.||Zlatin Zlatev||15/08/2002 13:37||"Is it possible to create colored PDF?..."
Klaus, use the HP Color LaserJet 8500 PS printer driver for producing the PS output and you will be able to produce colorful PDFs. We use this driver together with ghostscript in our PDF reporting engine.|
|9.||Trish Middleton||10/10/2002 20:17||This was very simple! I was having memory problems with FRX2WORD. This was free and it really works great! It comes out exactly like your report.|
|10.||Michael Brennan-White||06/11/2002 13:39||Wonderful Product. Works much faster than Acrobat for creating pages but is there a way to convert more than the first seven pages of the report to a PDF.
I can send a copy of the report if that would be helpful to diagnose the problem.|
|11.||Claude Fuchs||08/11/2002 08:19||Completely free and it's better than the Acrobat Writer/Distiller! Especially good for web reports...|
|12.||Paul James||08/11/2002 10:39||Debugging Tip:
Most problems are a result of a problem in your VFP report or your printer driver. If you will set the flag in the class so that "Report2PDF" does NOT delete the postscript file (.ps file), you can open the (.ps) file with Notepad and look for error messages. Also, look at my notes about manually creating and converting, because you can manually send your report to the Adobe printer driver (to create a .ps file), then via command-line you can call ghostscript to convert it.
Thanks - Paul James|
|13.||Jonathan Finch||14/11/2002 10:40||Works like a charm... excellent job.|
|14.||Mike Albert||14/11/2002 14:56||Hey VFP people. Here's the question. If given just a PDF file, how can you print it out without opening the pdf? I'm asking here because I want to be able to print out multiple PDF files programmatically without opening them (hundreds of these bad boys). This may not involve FoxPro or not, but I thought you may know how to do this. Is this a matter of converting the pdf to a .ps file? If so, can I convert a pdf file to something that isn't postscript like PCL5e (postscript is bigger and slower when printing)? Any help is appreciated. Thanks again.
|15.||Paul James||14/11/2002 21:30||One option would be to retain the Postscript file (.ps) when creating the PDF. This class has a property to tell it whether to delete it or not. Then, as you pointed out, the postscript file could simply be "redirected" to a printer port even using something as low-tech as a batch file.
Thanks - Paul James
|16.||Jonathan Finch||02/12/2002 12:35||For printing a .PDF without opening it, calling the Windows API seems to do the trick, assuming acrobat reader is installed. The Foxpro Foundation Classes have an _environ.vcx class library containing a _shellexecute class. Subclassing it with "open" changed to "print" in its Shellexecute method worked for me.|
|17.||Claude Fuchs||16/02/2005 04:34||I've got it working great from activevfp now! Color and everything!! I did modify it slightly to accomodate a vfp web/COM mtdll environment along with reverting back to using the ghostscript dll (along with Ed Rauh's heap class) for scalability reasons...|
|18.||Shz Khan||01/04/2009 23:47||When i use Print2pdf in Local machine it is working fine,
but when i use same application thru Citrix ,then it is giving error :
Error Loading Printer Driver|
|19.||Eduard Alexandru||07/05/2009 10:18||link broken :(|
|20.||Ivor Neo||30/06/2014 05:30||I had install the latest GhostScript (gs811w32) and PSDrivers, the demo program can run in VFP8 but not VFP9, it propmt "File Access denied when delete PS file and old pdf file before rename in MAKEPDF().|
More entries from this member
- BaseColors July 22, 2002
Have you ever needed an "on-the-fly" way to "tone down" your color palette to suit the needs of a particular client running 256 colors. Are you running any remote clients using Terminal Services, PCAnywhere, Citrix, etc. who don't want to push high color bandwidth? You don't want to have multiple versions of your screen though, right? Well, this little program can help!
- FoxFax - A simple class for using WinFax from VFP February 19, 2002
FoxFax is a class library that will allow you to send faxes from within Visual Foxpro. Because it is used as an object, it is very easy to set the desired properties, then call the methods. The download comes with a sample screen, table, and report.
- Search And Replace (for scx, dbf, frx, etc) January 19, 2002
This utility will perform a "Search And Replace" on any text within any property on a form, report, menu, database, class library, etc. or on any field in a table. Searches can be "exact" or "case-sensitive". You can process an entire folder at one time.
- Stringz - A collection of useful VFP functions. November 8, 2002
A library of Functions to manipulate "Strings" in VFP. These functions could save you a "lot" of time. Includes SmartProper(), Character-Time functions, All-in-one StringCheck(), RemoveGarbage(), CleanTable(), SupportEMail(), etc.
- TSAC - Terminal Services Advanced Client September 11, 2002
This is an example of use the TSAC ActiveX control embedded in a VFP form. It will allow you to embed a terminal services session "inside" your VFP application using only VFP and TSAC. I created these forms using VFP 7.0 and haven't tested under 6.0.
- vfpOutlook January 8, 2003
A FREE, very "usable" library for automating MS-Outlook. This "code based" class is very flexible and uses vfp tables to hold the Outlook properties, allowing you to support multiple versions, extend the capabilities, and make processing changes - all without requiring changes to the base code. It will support *any* of the Outlook folder/item types including Contacts, Appointments, EMail, etc. This class comes with a readme file, extensively documented code, test code, and test tables. It wi...
- X-Ray - more than a command window August 6, 2001
An easy-to-use and compact screen that allows you to have most of the functionality of the full VFP product at your fingertips at every client location!
It includes Code Block, Report Nuke, table cleaning, duplicates removal, an open tables grid, a command window, and a command history.
It is much more than a command window!