Naga
Naga

Reputation: 452

Export datawindow to PDF with help of any library

We have PB application which generates PDF files of data-window via PRINT functionality and with the help of Acrobat PDF writer. Now that we planned to remove any dependency of external application (printer like applications PDF writers), we are interested to generate PDF file with help of any plugable libraries and using the library api. Can someone please suggest if this is achieved, tried to find examples but in vain.

Upvotes: 1

Views: 1364

Answers (2)

Shenn Sellers
Shenn Sellers

Reputation: 172

Does your requirement exclude using the built in Ghostscript method?

I have a batch file that I run to set everything up, but there are many different ways to do it. An example of my batch file is below.

\\Waste-MV-1\Data\Apps\Shared\GhostScript\gs860w32.exe
copy \\Waste-MV-1\Data\Apps\Shared\GhostScript\PB\*.* C:\WINDOWS\system32
rundll32 printui.dll PrintUIEntry /dl /q /n "Sybase DataWindow PS"
rundll32 printui.dll,PrintUIEntry /if /b "Sybase DataWindow PS" /f %windir%\inf\ntprint.inf /r "file:" /m "HP Color LaserJet 2800 Series PS"
\\Waste-MV-1\Data\Apps\Shared\GhostScript\ghostscript_pdf.exe
  1. Install Ghostscript version 8.6 or higher.
  2. I then move the following files into the system directory. (These files can be found by searching in your "Sybase\Shared\PowerBuilder" directory.

    ADIST5.INF ADIST5.PPD ADIST5CS.PPD ADIST5CT.PPD ADIST5J.PPD ADIST5K.PPD

  3. Then I run a script to install the "Sybase DataWindow PS" printer depending on what OS is being used. (This is basically piggybacking off an existing driver).

WinXP...

rundll32 printui.dll PrintUIEntry /dl /q /n "Sybase DataWindow PS"
rundll32 printui.dll,PrintUIEntry /if /b "Sybase DataWindow PS" /f %windir%\inf\ntprint.inf /r "file:" /m "HP Color LaserJet 8500 PS"

WinVista...

rundll32 printui.dll PrintUIEntry /dl /q /n "Sybase DataWindow PS"
rundll32 printui.dll,PrintUIEntry /if /b "Sybase DataWindow PS" /f %windir%\inf\ntprint.inf /r "file:" /m "HP Color LaserJet 8500 PS"

Win7...

rundll32 printui.dll PrintUIEntry /dl /q /n "Sybase DataWindow PS"
rundll32 printui.dll,PrintUIEntry /if /b "Sybase DataWindow PS" /f %windir%\inf\ntprint.inf /r "file:" /m "HP Color LaserJet 2800 Series PS"

Win7_64bit...

rundll32 printui.dll PrintUIEntry /dl /q /n "Sybase DataWindow PS"
rundll32 printui.dll,PrintUIEntry /if /b "Sybase DataWindow PS" /f %windir%\inf\ntprint.inf /r "file:" /m "HP Color LaserJet 2800 Series PS"
  1. I run a small application that tests whether it was installed correctly or not. The DW is just text that says...

enter image description here

The code is use is...

string ls_filename = "C:\_APPS\Ghostscript.pdf"
string ls_printers
long ll_rows
int li_ret
boolean lbl_remove = false

SetPointer(HourGlass!)

ll_rows = dw_1.Retrieve()

if (ll_rows <= 0) then

    if (NOT DirectoryExists("C:\_APPS")) then 
        CreateDirectory("C:\_APPS")
        lbl_remove = true
    end if

    if (FileExists(ls_filename)) then FileDelete(ls_filename)

    li_ret = dw_1.SaveAs(ls_filename, PDF!, false)

    if (li_ret = -1) then
        MessageBox("ERROR", "Unable to complete installation.", StopSign!)
        return
    end if

    MessageBox("FYI", "Installation Complete!")

    FileDelete(ls_filename)

    if (lbl_remove) then RemoveDirectory("C:\_APPS")

    close(this)

else

    MessageBox("ERROR", "Unable to retrieve rows.~r~n~r~nCannot continue installation.", StopSign!)

end if
  1. As long as everything is installed correctly, then you can use the following code to save any DW as a PDF...

dw_report.SaveAs("", PDF!, true)

Upvotes: 1

Matt Balent
Matt Balent

Reputation: 2397

Now that Appeon Corporation has taken over development of PowerBuilder they are planning on incorporating native pdf generation in the next version (PowerBuilder 2017 - due out by end of q2 in 2017). At the present time there is not a way to create pdf files from PowerBuilder without some additional piece of software (be it Ghostscript or something else). You can create a COM dll(via .Net or whatnot) to do this but it still is a separate piece of software you need to distribute with PowerBuilder

Upvotes: 0

Related Questions