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!

Blank pdf from vfp report form

Status
Not open for further replies.

divaad

Programmer
Aug 11, 2015
13
US
Hello Everyone/anyone,

I am trying to convert a vfp report into a pdf so I can then email it.

I create the report and then convert it into pdf, but when I email it, the pdf is just a blank page.

I have prompted the printer to preview the report as well and this works but the pdf returns blank.

Any suggestion to what I am doing wrong? Below is my current code:

Thanks in advance for any and all advice,


REPORT FORM dbpaitlf NOCONSOLE TO PRINTER preview
********** Create pdf file for Margin Report **********
=MESSAGEBOX('Creating Margin Report pdf.', 0+64+0, "VBPA")
lcpdfname1 = "MarginReport.pdf"
lcFilename1 = lcpath+"PDFS\" + lcpdfname1
oPDF = CREATEOBJECT("wwXFRX")
oPDF.PrintReport(lcpath + "Reports\dbpaitlf" ,lcFilename1)
*******************************************************
 
Maybe because printer info of the (default) printer the report was created on is stored in the FRX/FRT.
That's why I always cleanup the report file. 15 years back I wrote something like this:

But that was presumably before VFP allowed you to control the printer environment from the Report menu.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks for all your help. I am testing a work around that lets me use the installed Adobe PDF printer and so far it is working. However this method opens the PDF preview window after the pdf is created. Is there a way to have this preview window close automatically? What I do is delete the pdf file after 'printing' and if this dialog box is open the file cannot be deleted since it is in use. Below is the code I am using. Thanks David


lcCurrWinDefaultPrinter = SET("PRINTER", 2)
oNet = CreateObject('WScript.Network')
oNet.SetDefaultPrinter('Adobe PDF')
REPORT FORM dbpaitlf noconsole TO PRINTER nodialog
oNet.SetDefaultPrinter(lcCurrWinDefaultPrinter)
<I send the pdf via email then erase/delete it>
erase D:\Apps\Int\PDFs\dbpaitlf.pdf
 
Thanks for your comment. I will push for the owner of my company to allow foxypreviewer. If anything I am at least learning some additional functionality of vfp, as you can probably tell I am new at it.

Thanks Again

David Jenkins
 
SET PRINTER TO NAME ('Adobe PDF') will also make REPORT FORM print to/with Adobe PDF and not change the windows default printer, so less code:

Code:
SET PRINTER TO NAME ('Adobe PDF') 
REPORT FORM dbpaitlf noconsole TO PRINTER nodialog
<I send the pdf via email then erase/delete it>
ERASE D:\Apps\Int\PDFs\dbpaitlf.pdf

Bye, Olaf.
 
Hi Olaf,

I tried your code above and the report does not print. I search the whole drive for it in case it got saved in a different location.

Thanks
David Jenkins
 
Maybe I am just 'nit' picking, but when you say:
I tried your code above
hopefully you did not execute the ERASE code line.

If so, no wonder you could not find the PDF document.

If you have your Adobe PDF 'printer' installed onto your workstation and it is named Adobe PDF then you should have been prompted for an output Destination Path & Filename when you executed the line: REPORT FORM <so on...>

If that did not occur, then either the Adobe PDF 'printer' is named something different, or something else is wrong.

Personally I use the Bullzip PDF 'printer' (free) for this sort of thing.

Good Luck,
JRB-Bldr

 
No I did take out the erase line to test it. When I use this code:

lcCurrWinDefaultPrinter = SET("PRINTER", 2)
oNet = CreateObject('WScript.Network')
oNet.SetDefaultPrinter('Adobe PDF')
REPORT FORM dbpaitlf noconsole TO PRINTER nodialog
oNet.SetDefaultPrinter(lcCurrWinDefaultPrinter)

the Adobe PDF save dialog box appears with the destination already where it needs to be with the filename as the report name (dbpaitlf) even if I leave out the nodialog line.

When I use this code:

SET PRINTER TO NAME ('Adobe PDF')
REPORT FORM dbpaitlf noconsole TO PRINTER nodialog

nothing happens that I can determine or locate whether I have the nodialog line or not. No dialog box of any kind and the program continues to run through the end. I am thinking that it might be a data session or data environment or something like that, that I am having trouble with, at this point, of wrapping my head around.

Thanks for your advice.
 
The report printer environment already was a topic of this thread. Once more:

If you modify the report, what does the report properties tell? In the Report Layout page, is the "save printer environment" (at the right bottom of the dialog) checked? Uncheck that and save the FRX.

As you temporarily set Adobe PDF as default printer and REPORT FORM then prints there, it should not be checked. If it was checked the default printer would be disregarded and whatever printer info embedded in your FRX report is used. If it's not checked, the Adobe PDF would also be used after SET PRINTER NAME ('Adobe PDF'), though. It tells VFP to use that printer instead of default without changing reports, but embedded printer info in FRX always has highest priority. Therefore it's only good to lock a report to a certain printer, embedding that info means no chance to switch printer at all.

So the expected setting is unchecked, Then the only thing, that coud make a difference is, Adobe has made the save dialog depend on the printer being default printer or not, but that would be weird.

For what it's worth, in any case look into your adobe pdf printer settings. Look out for printer settings about the output directory and file name. A few years ago you couldn't even set a default, but that might have changed. And if you didn't change anything, maybe some collegue or a windows or adobe update changed settings.

I made best experiences with CIB PDF Brewer. It's not free, but it even correctly puts graphics of Excel Sheet Footer/Header sections in the PDF, where even Adobe PDF printer failed. That test was 9 years ago, though.

Bye, Olaf.
 
Hello All,

I have installed FoxyPreviewer to print reports to PDFs. It works fine for Report Forms as indicated below:

DO d:\apps\FoxyPreviewerv299z30\FoxyPreviewer
Report form dbpaitlf object type 10 to file d:\apps\int\pdfs\dbpaitlf.pdf
SET REPORTBEHAVIOR 80


However for a report that launches with DO command (see below) the print dialog box opens and now the process is not automated.

DO d:\apps\FoxyPreviewerv299z30\FoxyPreviewer
DO dpbaitoo with "eod" && opens print dialog box
**DO dbpaitoo with "eod" to file d:\apps\int\pdfs\dbpaitoo.pdf - this is a syntax error
SET REPORTBEHAVIOR 80

How do you invoke the automated foxypreviewer like the first example for reports using the do command second example?

Thanks
David
 
Now you must decide where you want your answer. By asking exactly the same question in two different forums, with more or less the same readers, you only confuse us.

And by the way, FoxyPreviewer has it's own forum for asking this kind of specific questions. Click at the Issues link at
 
1. look into dpbaitoo, there has to be soe REPORT FORM command in there, too, if not Foxyypreviewer can't process that.
2. SET REPORTBEHAVIOR 90, before printing. What you afterwards would only influence following reports. 80 is the egacy mode NOT assisted with reportlisteners.

Bye, Olaf.
 
Hi Olaf,

Thank you for your response. I was able to trace the DO command to a .prg file where the 'REPORT FORM' command that I needed was located.

Thank you to everyone for their responses and for helping me get better at VFP.

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top