Simple Amyuni Use
(Updated: 2005.12.21 08:24:26 AM) |
| Edit -Find - New Topic - Recent Changes - Alphabetic Topic List - Random Topics - List Categories - Home |
FUNCTION ReportPrint
*
* Initialize variables and grab any parameters
*
ReportPath = Server.oConfig.oMyAppProcess.cHTMLPagePath+"Reports\"
&& wherever you want the report output to go
&& I usually place it in a REPORTS subdirectory of the virtual web
*---------------------------------------------
*
* Initialize (create) object and Phantom printer:
Pdf=CreateObject("CDINTF.CDINTF")
Pdf.PDFDriverInit("Ideate") && This is the printer name and must be unique
&& for the few seconds it is alive.
&& Append a SYS(2015) if you might have two or more com report requests at once.
&& Printer is destroyed upon report completion!
lcPDFName = SUBSTR(SYS(2015), 3, 10)+".PDF" && This is the output file name
Pdf.DefaultFileName = ReportPath+lcPDFName
Pdf.FileNameOptions = 1+2 && No prompt, use file name
*
* Set up your data, relations or cursors for the report here
http://www.easyinkz.co.uk printer cartridges
*Now print the report:
Pdf.SetDefaultConfig
SET PRINTER TO NAME "Ideate"
REPORT FORM Calendar NOEJECT NOCONSOLE TO PRINTER
* And redirect browser window to report file:
IF FILE(ReportPath+lcPDFName)
Response.redirect([Reports/]+lcPDFName)
* This is a valid url path to the report
ELSE
lcHeader=[No data available.]
lcBody= [Please note: There is no data matching the search criteria.]
THIS.ErrorMsg(lcHeader, lcBody)
ENDIF
Pdf.DriverEnd
SET PRINTER TO DEFAULT && If you feel you need to
* NOTE: SET PRINTER TO sets the VFP default printer - not the Windows
* default printer - so you may not need to bother to reset it
* - depending upon your environment.
lcPDFText = FileToStr("YourReport.pdf")
loHeader = CREATEOBJECT("wwHTTPHeader")
loHeader.SetProtocol()
loHeader.SetContentType("application/pdf")
loHeader.AddHeader("Content-Length",TRANSFORM(LEN(lcPDFText)))
loHeader.AddHeader("Accept-Ranges","bytes")
loHeader.AddHeader("Connection","Close")
Response.Rewind()
Response.ContentTypeHeader(loHeader)
Response.Write(m.lcPDFText)
| Edit -Find - New Topic - Recent Changes - Alphabetic Topic List - Random Topics - List Categories - Home http://www.west-wind.com/ - 2010.07.29 09:50:50 AM EST |