wc Home 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
Making waves on the Web with Visual Foxpro   
Search:

Here is a simple way to implement the Amyuni ActiveX? in any WWWC VFP application - and of course with straight VFP with minor mods. It uses the DLL rather than the clumsily implimented FLL.

Because it uses redirection to view the PDF in the user's browser, the report destination directory needs to be regularly purged of old files. I do this as a part of the automated nightly backup procedure.

The CDINTF.DLL must be properly registered on the web server. The Amyuni docs have instructions to do this.

This technique creates a printer that survives only a couple of seconds - long enough to print and no longer. Odds of printer name collision is very low, but you can probably eliminate any chance by appending a SYS(2015) to the printer name to assure uniqueness.

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.



Michael Hogan

If you are getting a file/save as dialog even though you are using the NO PROMPT option (in code above), verify that the application's user identity has rights to the destination directory for the report AND to the Amyuni portion of the registry. Under Windows 2k it is under:
HKEY - Current - Config --> Software --> Amyuni PDF Converter --> Options.

Michael Hogan

The above methodology saves the resulting PDF file to disk, with the intention of returning either a link to the resulting file, or a REDIRECT to it. When instead attempting to return the contents of the PDF within the content stream to the browser (instead of returning a link to the resulting file), I (and many others) occasionally have the problem of a blank page being displayed by Acrobat Reader. Some solutions to this are as follows (message numbers are from the west-wind message board):

1) If you have control of the client workstations, you can set Acrobat Reader to open in it's own window. This procedure is outlined at the Adobe web site, but I also have it at: http://www.id-8.dynip.com/scheduler/Help/FAQ.htm

2) Write the PDF file to disk, and provide a link to it (or redirect to it): http://www.west-wind.com/webconnection/docs/_0LC1DIHM7.htm

3) Include the file size as a 'content length' header parameter - msg:07R0TNZLW
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)

4) return "Response.Expires = 0" before anything else - msg:0QG0DZJMC

Michael Hogan
http://doppelkarte.org/pdf/doppelkarte_org-vergleichen.pdf
---
[2002.11.06] I just spent this afternoon further researching the issue with Adobe and www.PlanetPDF.com. It appears that all web developers (not just West-Wind? users) are bumping into this issue (not being able to stream a PDF file to many IE browsers). Tips 3 and 4 above are not a reliable solution.

Michael Hogan
---
Category PDF Category User Extensions

Edit -Find - New Topic - Recent Changes - Alphabetic Topic List - Random Topics - List Categories - Home
Making waves on the Web with Visual Foxpro   
http://www.west-wind.com/ - 2010.07.29 09:50:50 AM EST
Search: