PowerBuilder 12.5 Classic PDF SaveAs creating files of 0 size on Win7 x64

后端 未结 2 930
闹比i
闹比i 2021-01-23 13:37

Platform:

Windows 7 x64

PB 12.5 Classic

Ghostscript 9.07 (both x32 and x64 are installed)

HP Laserjet PS printer installed as

2条回答
  •  一整个雨季
    2021-01-23 14:21

    Its about 18 Months ago that we had this problem. IIRC the basic problem is that the driver for the printer must be 64-Bit and you must then use the appropriate 64-Bit Ghostcript exe gswin64c.exe. As far as I see it, Powerbuilder being a 32-Bit application is hard wired to gswin32c.exe.

    I ended up having to practically manually do what Powerbuilder does. First I had to find the path of gswin32c.exe or gswin64c.exe by searching the relevant parts of the Registry. This means searching both the 64-Bit part and the 32 Bit-part, since our application does not just run on 64-Bit machines. I think I ended up using ProcessMonitor and ProcessExplorer to watch Powerbuilder in action and mimic what it was doing.

    Once you have determined the path of the Ghostscript-EXE you can manually set the Printer to "Sybase DataWindow PS" and do pDw.Object.DataWindow.Print.FileName = sz_pathps where sz_pathps is a path to a temporary file where your PostScript file will be produced via the distiller. You then do pDw.print(false,false) and you have a PostScript file.

    Then you can manually call GhostScript using the path to the exe that you found in the registry. The command line parameters I use are

    -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -sOutputFile=xxxxx.pdf -c .setpdfwrite -f yyyyy.ps

    xxxxx.pdf is the path of the PDF-File you wish to produce and yyyyy.ps is the path of the PS-File that you produced using the distiller.

    Manually calling the GhostScript-Exe means calling CreateProcess and then subsequently WaitForSingleObject.

    This of course means you are not able to use dw.saveas any more and will have to offer some that of Menu or Icon that does the job.

    This is indeed truly messy but I had no alternative. It was "must have" functionality, so I had to do it.

    There you are, this is my first contribution to stackoverflow and I hope it helps.

    Greetings,

    Richard Sharp

提交回复
热议问题