Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Version 3 getting close!
Message
General information
Forum:
Visual FoxPro
Category:
ActiveVFP
Miscellaneous
Thread ID:
00993941
Message ID:
00995996
Views:
25
This message has been marked as the solution to the initial question of the thread.
It seems that there is no problem with the GS.

First I had Print2Pdf functionality in MTDLL (I called COM exe from MTDLL
to REPORT FORM because it doesn't work in MTDLL) and I found that SET
PRINTER TO NAME doesn't work in MTDLL i.e. generated PS file is not
generated with the PS printer driver but with the default one (which I have
Laserjet 4...)

Then I added SET PRINTER TO NAME "Generic color postscript" to the COM exe
(which only purpose is to run REPORT FORM) and PDF was generated correctly.

Then I looked for your code (PDFrun) and realize that it is COM exe too and
there should not be any problem. I tested PDFRun as follows:
* 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
   
ENDDEFINE
Result => CORRECT PDF was generated.

If you still can't get it to work try next:

locate the line:
report form (lcReport) &lcExtra noconsole to file &lcPSFile
from 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 :)

AT

P.S. Even if I didn't found problem with the GS, you may want to install the newest version of GS (8.50). You can find it from
ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/gs850/gs850w32.exe
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform