Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to - VFP report to PDF
Message
General information
Forum:
Visual FoxPro
Category:
FoxWeb
Miscellaneous
Thread ID:
00733820
Message ID:
00733853
Views:
78
>Just starting out with Foxweb and have one very basic question. I have a VFP report already designed that excepts a cursor for its data source. This report works well in VFP app and prints one invoice per page as expected. I would like to be able to use Foxweb to print this report in PDF format.
>
>1. Would someone give me a basic example demonstrating how to use PDF to print a VFP report?
>
>2. Does PDF respect page breaks like VFP does when printing reports or will the PDF spill over and use its own break based on available print space on each page number?
>
>
>Thanks for your help.
>
>John

Take a look at WestWind Web Site. They had a white paper and utilities on creating PDFs via the web. I used that as a guide when I implemented it in FoxWeb.

The basic call looks like:


SET PROCEDURE TO WWAPI ADDITIVE
SET PROCEDURE TO WWPDF ADDITIVE
oPDF=CREATE("wwPDF","WINNT")
* Set this to hard code where the ini file is oPDF.SetAcrobatIniFile("c:\windows\win.ini")
oPDF.nTimeout = 20
* Procurement Status needs to be in landscape mode
oPDF.SetLandscapemode(.T.)
IF vp_FidId = 'SPLIT'
llResult = oPDF.PrintReport("pssduesplit2.frx",'D:\Engineering\pdfs\' + mtmppdffile)
ELSE
llResult = oPDF.PrintReport("pssdelvsumm3.frx",'D:\Engineering\pdfs\' + mtmppdffile)
ENDIF
* IF We want text from pdf use this mpdftextfile = oPDF.PrintReportToString("prt_proc.frx")
*
* close the temporary database
USE
IF NOT llResult
RELEASE oPDF
* We have an error lets inform the user
m.errortitle = 'PDF File could not be generated'
mhtmerrmsg = 'For some reason the PDF file could not be generated. Please try again, if problem persists send email to the address below.'
* PDF Problems
SELECT form_text FROM html_frm WHERE form_id LIKE 'errormessage' INTO ARRAY formtxt
html_out = mergetxt(m.formtxt)
RETURN
ENDIF
RELEASE currfy, currpone, currptwo, currmone, currmtwo, centfy, centpone, centptwo, centmone, centmtwo
RELEASE oPDF
RELEASE PROCEDURE WWAPI
RELEASE PROCEDURE WWPDF
* We generated the PDF image so lets show the user
* Return the page with our PDF image location
html_out="Location: https://ammoeng.crane.navy.mil/pdfs/"+mtmppdffile +CHR(10)+CHR(10)
RETURN

The above code uses the older FoxWeb version, but you can easily translate it to the new version. The libraries are what was on West Wind site that you download. You might also find them on the UT download section.

As for respecting page breaks. I have had not trouble.

HTH
Bret Hobbs

"We'd have been called juvenile delinquents only our neighborhood couldn't afford a sociologist." Bob Hope
Previous
Reply
Map
View

Click here to load this message in the networking platform