Tuesday, August 24, 2010

Printing Data-Windows using PowerBuilder as a Web Application!

With the assistance of Sybase, we were able to resolve one of the two issues I have been having in converting this application over from a client/server application to a .net web application, and that is the print issue. I am writing this because after months of researching I found nothing online to help me, I am NOT saying it is not out there, I am saying I did not find it.
So this is what I have: first we need to make sure that we have the GhostScript properly installed on the server. This third party tool is essential for taking your datawindows and converting them into a PDF. The next part of this process is, in my opinion, a little corky. After you click on your standard print, and the “Please wait” dialog box leaves the screen, you need to look in the upper right hand corner of the Browser area, you know – below all your taskbars. In this corner you’ll notice a new icon (I have two icons the one for “Exit” is always there) , click the one that references PDF’s.
By clicking this button you’ll notice a file that has the same name as the data window that you are trying to print. What has happen is a temporary PDF file as been written to your server. This dialog box shows you all of the datawindows that you are requesting to print and they have converted them to a PDF.
Now you must select the file that you want to print by clicking the file name, it should be a hyperlink to the PDF and this will open the Adobe Reader and now you can print to your locate printer.
I am not sure if this is a Sybase or GhostScript process but it is the one that works. I would love to know if there is an easier way, but after two weeks I am just glad it is working.

1 comment:

Anonymous said...

Hi, Jim

You can have an alternative way of displaying PDF reports, not using the standard Print Manager functionality of the webforms.

You can issue SaveAs() method to have your DW contents exported to PDF-file within the web user session folder and then issue DownloadFile() to open it for viewing like this:

#if defined PBWEBFORM then
if dw_rep.SaveAs("rep.pdf", PDF!, true) = -1 then
return "Error generating PDF contents"
end if
DownloadFile("rep.pdf", true)
#end if

However, there were some complaints in the "sybase.public.powerbuilder.net.webform" newsgroup that the new browser window is shown below your main application one. To avoid this, read my answer in the thread started by Mark on 26 May 2010.

Kind regards,
Ivaylo Ivanov