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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing to .pdf file without dialogue

Status
Not open for further replies.

AndrewMozley

Programmer
Oct 15, 2005
623
GB
I feel that this must have been asked many times before! I have an application which I have installed at a few sites, and I want to allow printing to .pdf files.

At present I am using PDF Creator (which is free) and this appears as a printer which the user may select. At run-time the user is invited to select a destination folder and file name, and this works fine.

I would like however to be able to complete the whole task within the application: I will have created the .dbf with the results that I wish to print, decided what .frx/.frt layout I wish to use, and also determined the name and folder of the output .pdf file that I want to create. So I would like to generate the file without requiring further input from the user.

Is it possible to do this? I had looked at XFRX which may have the facilities, but although I could afford $249, I get the impression that I am not allowed to distribute the XFRX application to my customers - so it could only be for my in-house use.

If anyone has produced .pdf files as described, and can point me towards a step-by step guide to installing and using a suitable product (free would be nice!) I would be grateful.

Thanks. Andrew
 
I had looked at XFRX which may have the facilities, but although I could afford $249, I get the impression that I am not allowed to distribute the XFRX application to my customers - so it could only be for my in-house use.

That's not so. You are allowed to distribute the XFRX runtime files. At least, that was the case when I was using it. As far as I know, that hasn't changed, although I'm a bit out of touch with it.

XFRX is a very simple way of doing PDFs. Then again, if someone can give you the answer to your question (and I'm sure someone can), that would be a better solution - and would save you a bit of cash.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Andrew,

I'm not familiar with PDF Creator, but I've just had a quick glance at the documentation (see It talks about enabling "automatic saving" (see under Profile Settings / Save), which looks like what you are looking for.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks tbleken. I have had a brief look at Foxypreviewer and this could be of interest. Does Foxypreviewer allow an application to generate a .pdf file without intervention at run-time from the user ? Or does he have to use the toolbar.

As I mentioned I need to be able to generate a .pdf document directly from the application. If this is the case, is there a utility that you can recommend to read .rar files so that I can download the program.

Andrew
 
Regarding FoxyPreviewer, the answers are YES to all your questions. And it's so easy, just read the documentation.
 
Just to go back to XFRX for a moment, I just checked their website. It is indeed royalty-free. There are no restrictions on distributing the run-time components.

But that's not to detract from TBLeken's suggestion of using FoxyPreviewer, which would also be a good choice.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thank you Mike and tbleken. I will download one of these packages and see whether it offers the facility to produce .pdf files directly from the program (without user intervention at run-time). If anyone has done this successfully, it would be useful to see a copy of the code they have used and any installation notes, but I will press on anyway!

Andrew
 
What is wrong with

Code:
* print PDF
set printer to name PDFCreator
report form XXXXX to printer noconsole 
set printer to default

* print on the default printer 
report form XXXXX to printer noconsole
 
AndrewMozley said:
If anyone has done this successfully (without user intervention at run-time)
With some small changes in first first link posted previously by me, I've already done it using PDF Creator.
I'm sure you can make those changes by yourself.
But, obviously, Foxypreviewer or XFRX are very good tools.

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
For a number of years I used Bullzip. It is also Free.

I set it up in a pre-configured state such that it ALWAYS wrote to the same filepath & filename (local to the workstation)
IN that way, the VFP application always 'knew' where to look for the file and what it was called.
Then it would immediately go to that known location and did a COPY FILE (origPDF) TO (newPDF)
The 'newPDF' could be anywhere on the network that was reachable by the application.

That enabled the VFP application to print the PDF without the need for any user dialog and, since the VFP application 'knew' where it wanted the final path to be and what the final filename should be, it could make those changes during the COPY FILE execution.

The only down-side I encountered was that each installation of Bullzip on each workstation had to be manually configured to run that way.
I have heard (but not tried it) that Bullzip can be run with from command line prompts and do the same thing.
That would alleviate the need to manually configure each Bullzip installation on the individual workstations.

I am using XFRX now, but it is now Free.

Good Luck,
JRB-Bldr
 
What is wrong with

Code:
* print PDF
set printer to name PDFCreator
report form XXXXX to printer noconsole 
set printer to default

* print on the default printer 
report form XXXXX to printer noconsole

The other problem with this solution is that you have to make sure PDFCreator is installed on every machine with the right name. As much as possible, I like to stay away from solutions that require specifically-named printer drivers.

Tamar

Tamar
 
TamarGranor said:
The other problem with this solution is that you have to make sure PDFCreator is installed on every machine with the right name. As much as possible, I like to stay away from solutions that require specifically-named printer drivers.

Well, that goes for anything external to the application that might change. If it will require a recompile to change it, I like to stick it into a config file and read that at runtime so when it changes I only need to change the config file. (And this includes file locations, mail servers & credentials, etc.)
 
Did you try FoxyPreviewer? You include one file in your project, and add one line of code. To create a pdf, Report Form yourform to yourfile.pdf.
 
Yes, anything external raises issues, but printer drivers in particular are something that users can and do play with.

Tamar
 
Thanks Vilhelm

Very grateful for your suggestion. I should have replied earlier but have been away. I do indeed have PDFCreator installed on my machine. I have been checking out the first of Mike Gagnon’s examples, which looks as though it does what I want. However I rather failed at first base. When I tried to execute the command :

Code:
oPDFC  = CREATEOBJECT("PDFCreator.clsPDFCreator","pdfcreator")

I get the error message :
Class definition PDFCreator.clsPDFCreator is not found.

Is there some additional part of PDFCreator that I need to install on my machine (and how do I do that) ?

Thanks tbleken. I will check out Foxy Previewer, but is there any published documentation? I have found and printed a document from the website, effectively the pages which I see when I follow your link (Project Description | Features | Preview Toolbar &c). It all looks good, but I could not see a reference to printing .pdf files and I was not sure that it would allow generation of a .pdf file to a specified folder / filename, without interaction from the user; this is what I am looking for.

If you have some sample code to do this using Foxy Previewer that would be very helpful. Or is a more detailed overview or guide available? I have downloaded the product and extracted the files from the .rar file. However I was not able to find there a user’s guide or a programmers guide. Are these available elsewhere on the FV site ?


Thanks Tamar. Yes, I recognise that it is not entirely satisfactory that the users all need to have the PDFCreator printer defined with the same name. However on the site where I am installing my software there are only three workstations using my application, so I will make sure that the printers are set up correctly when I upgrade the software. In the longer term I suppose that I might (at run-time) check to see whether the printer exists on that machine and prompt the user if it does not.

Andrew
 
This is not just an end product to use. If you haven't yet downloaded any VFPX project: You get full sources, you can change it as you like (and may contribute changes back).

The general idea of foxypreviewer is, it replaces the standard report preview. And it's toolbar offers saving to file.
Since you have that code, you can also make the preview not display but save to a file itself and then close the preview mode, as if the user just would do so.
On the other side you may also extract the code portions generating PDFs and create a foxyoutput app. Foxypreviewer just replaces the native reportperview.app (mainly by setting _reportpreview to it) and you can also do so with reportbuilder.app and reportoutput.app or the corresponding system variables.

Bye, Olaf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top