views:

793

answers:

5

I have a grid datawindow with a picture in it's background (with dimensions of an A4 page) and I would like to export both data and the picture as a (single page) PDF file. I used several combinations of the following commands but at most I got a 0-sized pdf.

//dw_1.Modify("Datawindow.Export.PDF.Method = Distill! ")
//dw_1.Modify("DataWindow.Export.PDF.Method = XSLFOP! ")

dw_1.Object.DataWindow.Export.PDF.Method = Distill!
//dw_1.Object.DataWindow.Printer = "\\prntsrvr\pr-6"
dw_1.Object.DataWindow.Export.PDF.Distill.CustomPostScript="No"
dw_1.SaveAs("c:\dw_one.pdf", PDF!, false)

User’s guide (on page 533) says:

… the data is printed to a PostScript file and automatically distilled to PDF using GNU Ghostscript…

Installing Ghostscript

For licensing reasons, Ghostscript is not installed with PowerBuilder. You (and your users) must download and install it before you can use this technique…

Does anyone have any idea what is the procedure?

EDIT THANK YOU ALL. Installing ghostscript proved to be enough. I only cannot understand why the procedure is successful on some fellows PCs (using Method = XSLFOP!) without using ghostscript :-/

+3  A: 

We've got it working here. From our internal wiki:

  • Install ghostscript on your workstation (8.50 or 8.15 recommended)
  • Make sure that the ghostscript files in the Powerbuilder DLL directory
  • Ensure that there is a directory in the same place containing the default postscript drivers supplied by Sybase.
  • Powerbuilder uses the Adobe Postscript Driver (which can be downloaded free from Adobe.com). This must be named 'Adobe DataWindow PS'

We're using version 1.06 of the postscript driver which you can download here:

Colin Pickard
+3  A: 

Your code looks fine and is in line with my code that I just checked that does something similar. Verify that ghostscript is installed correctly.

For debugging purposes I would try using a much simpler datawindow without the bitmap background.

dhammy
+4  A: 

Ghostscript and Printer setup for PowerBuilder

Administrative privileges are required to install the printer. We are using this setup on XP.

These instructions use an HP printer driver instead of the one supplied by Sybase. If for some reason you don't have this driver, you can download it from HP. The HP driver has the following advantages:

  • Generated PDFs can be read by a Screen Reader (YMMV, but the Sybase driver output isn't readable at all.)
  • Driver is digitally signed for installation on systems that require signed drivers

Needed files

  • gs860w32.exe from http://pages.cs.wisc.edu/~ghost/ (you can try a later version if you like. 8.60 is working fine for us.)
  • Driver files in C:\Program Files\Sybase\Shared\PowerBuilder\drivers (path may vary depending on installation)

Ghostscript

Install gs860w32.exe

  • Install to C:\Program Files\gs
  • Check All Users
  • Check Install Ghostscript Fonts

Sybase DataWindow PS Printer

The printer name is case-sensitive and has to be exactly what is inside the quotes. There is no space in “DataWindow”. The easiest way to get it right is to copy from this document and paste it in.

  • Open Control Panel, Printers and Faxes
  • Choose Add printer (next)
  • Choose Local printer, uncheck Automatically detect and install my Plug and Play printer (next)
  • Choose Use the following port, select FILE: (next)
  • In the left-hand list, select 'HP' for the manufacturer
  • In the right-hand list, scroll down and select 'HP 8150 Series PS' (next)
  • Printer name "Sybase DataWindow PS"
  • Use as default printer select No (next)
  • Leave Do not share selected (next)
  • Print test page, select No (next)
  • (finish)
Hugh Brackett
+2  A: 

As a minor addition to the others, I've never had to Modify() any of the Export attributes; I just SaveAs(). My understanding is that these attributes are for trying to go non-Ghostscript routes, but I don't recall hearing of anyone successfully doing this.

To simplify your test, you might want to see if you can right click on the Preview pane in the DataWindow painter to see if there is a "Save Rows As..." option. (I don't have 10.5 installed at the moment, so I can't see if it's available in that version.) It will save you running the app, and at least test the basic functionality before getting it to run in PowerScript.

Good luck,

Terry.

Terry
No Modify() here either. We just saveAs().
Hugh Brackett
A: 

Guys, I used the "Ghostscript and Printer setup for PowerBuilder" like Hugh Brackett said, and running through the powerbuilder the save as is working fine, but when running through the executable application save as command saves a pdf file in the directory i wanted but with 0 kb? How does this happen?

The code is this:

integer li_saved

li_saved = dw_1.SaveAs("c:\ergose\temp\dw_one.pdf", PDF!, false)

and li_saved is 1 after the command execution...

Thanks in advance !!!

sgian76
Have you verified that the executable uses the same dlls?
gd047
It sounds to me like the PostScript file has been created (PB printed to the PowerScript printer driver), but GhostScript has choked somehow. Maybe you can track down the .ps file and run it through GhostScript interactively to see the error. Or, check for a GhostScript update.
Terry
That's usually caused by PB not finding GhostScript. Make sure you install GhostScript with the installer, and make sure you install for all users. This creates registry keys that PB uses to find GhostScript. Our software checks for these keys as well as the Sybase DataWindow PS printer before it tries to save as PDF. Also, in case it isn't clear each workstation must have both the printer and GhostScript installed in order to save as PDF.
Hugh Brackett
Also, Process Monitor http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx is useful to find out what's going wrong. Set the filter to the name of your program to hide all the activity you aren't interested in.
Hugh Brackett