1

Here's my problem. I currently am trying to print a DataWindow to a PDF file in PowerBuilder 12.5. I got some code, and it currently looks like this.

//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)

I installed GhostScript on the machines, but I read at some places that I would need to create a new printer and set some drivers in the PB driver directory. Could anybody enlighten me?

Terry
  • 6,160
  • 17
  • 16
user1519082
  • 33
  • 1
  • 2
  • 4

2 Answers2

3

I just did this myself.

you want to install ghostscript http://www.ghostscript.com/download/gsdnld.html and have the right one for your OS (32bit vs 64bit) I used the 9.02 version myself

You install it as an administrator for the machine, and the installer program should auto generate the "Sybase Datawindow PS" Printer device for you.

Once that is done you don't have to set any thing in the datawindow for for it to work, the defaults are ok

Just do: dw_1.saveas( "c:\somefilename.pdf", PDF!, false ) and viola! a pdf

Carl Wyles
  • 31
  • 1
  • Actually, I believe the printer is auto-generated on the first dw.SaveAs(), but sometimes it chokes on permission-constrained environments (hence the advice about running as admin). Having an installer do the printer creation could be prudent, if you're up to it. And to drive home the point of the "Just do" paragraph, you need to do **nothing more than the SaveAs() in most cases. The commands to customize the DW's PDF generation options are more likely to cause you problems. – Terry Jul 12 '12 at 05:15
  • A PDF alright but the datawindow format is not properly maintained. The lines drawn in the datawindow do not appear and hence the formatting looks bad. If any image was placed in the datawindow that also do not come in the PDF. Frankly I have not been able to use this as a method of PDF generation ever. I had asked my clients who need PDF to install PrimoPDF and print to it instead manually as I have not been able to control an automatic PDF creation of a datawindow using PrimoPDF as it launches a window that asks various details from the user and then saves the PDF. – somnath Jul 12 '12 at 13:41
  • 1
    @somnath I haven't run into similar problems, nor have I heard of anyone complaining about this problem in the newsgroups. I have little doubt that there are difficulties integrating two products from different vendors, and your advice to be aware of options is good. However, my expectation (from experience and from other users) is that as far as image fidelity goes, the PB/GhostScript option is pretty adequate for most. In fact, at the moment, it's too much so: it's rendering background gradients wonderfully, and I don't want them there for the print! (Need to Modify() them off for the print) – Terry Jul 12 '12 at 14:07
  • Thanks @Terry for letting me know the world experience! I was also wondering why it is like this in shambles! Do you know of any step by step guide to achieve the intended results? I may be not doing something or doing something wrong then that is causing such issues. I can arrange for samples to show what my experience has been in a day or so. – somnath Jul 12 '12 at 18:12
  • @Terry thanks a lot! After so many years it finally worked. I was not setting up the DW settings properly. I did that and the PS printer driver together and now it came out perfectly with all objects and images and everything! :) Thanks so much! – somnath Jul 12 '12 at 18:24
  • 1
    @somnath Best I can guess is that the extraneous settings the OP were using were also messing with your output. Credit to Carl. FWIW, I think the documentation on these settings is confusing, and you aren't the first person I've heard discussing problems around these settings, although it's the first time I've heard the results described quite this way. Good to hear you're set. Also heads up: PDF generation within PB.NET is 100% internal from 12.0 (i.e. no GhostScript), and the same is expected to be true for Classic as of 15.0 (next version after 12.5). Be happy... now. – Terry Jul 13 '12 at 02:29
  • @Terry: I would write a utility to zap and restore gradients. I have services in our mid tier to manage various column properties. Most of the services add an attribute to the tag (PFC style) to hold the original value. The methods typically take an array of columns to modify. Passing an empty array modifies all columns. I've removed thousands of lines of code from our application that were twiddling object properties in DataWindows and avoided writing many thousands of lines more. [Once and Only Once](http://c2.com/cgi/wiki?OnceAndOnlyOnce) is essential when modifying DataWindows. – Hugh Brackett Jul 14 '12 at 15:17
  • @HughBrackett Yes, speaking of PFC, the intention is to enhance the PFC DW Report service (mildly flawed in implementation IMHO, but fixed in my version) to handle gradients too. I find the gradients more vexing in printouts, but I never thought of making the Report service an option for PDF generation. There's another item for my PFC To Do list. And, I couldn't agree more about code reuse; my current nightmare is fixing apps that were built around copying code over and over again. If code reuse was done right the first time, there'd be less time spent on fixes and more on new features. – Terry Jul 15 '12 at 02:28
  • @Terry The printing was working fine on XP x32. We now shifted to W7 and W8 x64 and now surprisingly the same program is generating 0 byte PDF files. We have installed the x64 version of Ghostscript. Any idea what could be wrong? I have tested with both x32 and x64 with same results. – somnath Apr 05 '13 at 19:43
1

install do pdf8 along with ghost script. it will ask you during the run time to save it as pdf . click ok and after waiting of approx 2 mins it will convert your data window as pdf. for more details watch this video https://www.youtube.com/watch?v=BfuV7a_4ONU

Muhammad Saeed
  • 81
  • 3
  • 10