在任何库的帮助下将数据窗口导出为 PDF

Export datawindow to PDF with help of any library

我们有 PB 应用程序,它通过 PRINT 功能并在 Acrobat PDF writer 的帮助下生成数据的 PDF 文件-window。现在我们计划删除任何外部应用程序(打印机,如应用程序 PDF 编写器)的依赖性,我们有兴趣在任何可插入库的帮助下生成 PDF 文件并使用库 api。有人可以建议是否实现了这一点,试图找到例子但徒劳无功。

您的要求是否排除使用内置的 Ghostscript 方法?

我有一个批处理文件,我 运行 设置了所有内容,但是有很多不同的方法可以做到这一点。下面是我的批处理文件的示例。

\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. 安装 Ghostscript 8.6 或更高版本。
  2. 然后我将以下文件移动到系统目录中。 (这些文件可以通过在您的 "Sybase\Shared\PowerBuilder" 目录中搜索找到。

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

  3. 然后我 运行 一个脚本来安装 "Sybase DataWindow PS" 打印机,这取决于正在使用的 OS 打印机。 (这基本上是搭载现有的驱动程序)。

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. 我运行一个小应用程序,测试它是否安装正确。 DW 只是文字...

使用的代码是...

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. 只要一切都安装正确,那么你就可以使用下面的代码将任何DW保存为PDF...

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

现在 Appeon Corporation 已经接管了 PowerBuilder 的开发,他们计划在下一版本中合并原生 pdf 生成(PowerBuilder 2017 - 将于 2017 年第二季度末发布)。目前,如果没有一些额外的软件(无论是 Ghostscript 还是其他软件),还无法从 PowerBuilder 创建 pdf 文件。您可以创建一个 COM dll(通过 .Net 或诸如此类的东西)来执行此操作,但它仍然是一个单独的软件,您需要使用 PowerBuilder

分发