* DoPdfDemo.prg ox = CreateObject("myserver.myclass") ox.DOPDF()
* myserver.myclass which is MTDLL and calling PDFrun * myclass.prg DEFINE CLASS myclass AS session OLEPUBLIC FUNCTION DOPDF() **LOCAL lcFile,lcNewPath,lcCompany loPDF=CREATEOBJECT("PDFRun.Print2PDF") ** * files older than 20 Minutes(1200 ms.), erase. 3rd param is path - can be hardcoded ** oUtil.DeleteFiles('pdf',1200,STUFF(oProp.AppStartPath, AT(oProp.AppName,oProp.AppStartPath,OCCURS(oProp.AppName,oProp.AppStartPath)), LEN(oProp.AppStartPath),oProp.AppName+'r\pdffiles\')) ** lcCompany=oRequest.Form("Company") **IF ISNULL(lcCompany) .OR. EMPTY(lcCompany) ** oPDF.cRecordSelect = [SELECT * from ]+ oProp.DataPath+[customer INTO CURSOR tcursor] **ELSE ** oPDF.cRecordSelect = [SELECT * from ] + oProp.DataPath+[customer ]+; ** [WHERE UPPER(company)=ALLTRIM(UPPER(']+lcCompany+[')) INTO CURSOR tcursor] **ENDIF *** the following properties are coded for portability. They may be hardcoded instead. if isnull(loPDF) return .f. endif loPDF.cPhysicalPath = "C:\DEMO\" loPDF.cOutputFile = "p2demo.pdf" loPDF.cReport = "d:\program files\microsoft visual foxpro 9\test\p2demo.frx" * llResult = loPDF.Main() llResult = loPDF.GetOutput() ** if !llResult or loPDF.lError ** =messagebox("This error ocurred creating the PDF:"+chr(13)+alltrim(loPDF.cError),48,"Error Message") ** endif loPDF = .NULL. release loPDF return .t. **oPDF.cPhysicalPath=STUFF(oProp.AppStartPath, AT(oProp.AppName,oProp.AppStartPath,OCCURS(oProp.AppName,oProp.AppStartPath)), LEN(oProp.AppStartPath),oProp.AppName+'r\pdffiles\') **oPDF.cLogicalPath=[http://]+oRequest.ServerVariables("HTTP_HOST")+STUFF(oProp.ScriptPath, AT(oProp.AppName,oProp.ScriptPath), LEN(oProp.ScriptPath),oProp.AppName+'r/pdffiles/') **lcFile=oPDF.GetOutput() && generate output, return temp file name **lcNewPath=oPDF.cLogicalPath+lcFile && new URL **oResponse.Redirect(lcNewPath) && redirect browser to created file ENDDEFINEResult => CORRECT PDF was generated.
report form (lcReport) &lcExtra noconsole to file &lcPSFilefrom pdfrun.print2pdf and add next line after it:
report form (lcReport) &lcExtra noconsole to file "C:\SOME_EXISTING_DIR\DEMO.PS"and then notepad the DEMO.PS file. If it is PCL-garbage like:
%-12345X@PJL COMMENT HP LaserJet 4M Plus @PJL SET PAGEPROTECT=OFF @PJL SET PAGEPROTECT=AUTO @PJL SET RET=MEDIUM @PJL SET ECONOMODE=OFF @PJL SET RESOLUTION=600 @PJL ENTER LANGUAGE=PCL E*t600R&u600D*r0F&l0o1E&l0S&l0H&l26a8c1E*p0x0Y*c0t5611x8177Y&l1X*b0M *c16534D)s6836W H <P d à þ ¿ ÿ Comic Sans MS þg f PA GTT € cvt \ø8â Œ 4fpgmé a| À %gdir headœ¦£ú è 6hhea”Ç $hmtxÐ/ãF D ømaxpe p < prep>1®… \ ÷f . . .instead of something like the next:
%!PS-Adobe-3.0 %%Title: d:\vfox6tools\prn2pdf\P2DEMO.FRX %%Creator: PScript5.dll Version 5.2.2 %%CreationDate: 3/15/2005 17:18:1 %%For: administrator %%BoundingBox: (atend) %%Pages: (atend) %%Orientation: Portrait %%PageOrder: Special %%DocumentNeededResources: (atend) %%DocumentSuppliedResources: (atend) %%DocumentData: Clean7Bit %%TargetDevice: (Acrobat Distiller) (3011.104) 0 %%LanguageLevel: 3 %%EndComments . . .then PS printer wasn't selected when output was generated to the file. Correcting that you are up and runing again :)