借助任何库将数据窗口导出为PDF

时间:2016-08-24 13:08:24

标签: powerbuilder

我们有PB应用程序,它通过PRINT功能并在Acrobat PDF writer的帮助下生成数据窗口的PDF文件。现在我们计划删除外部应用程序的任何依赖项(打印机类应用程序PDF编写器),我们有兴趣在任何可插入库和使用库API的帮助下生成PDF文件。有人可以建议如果这样做,试图找到例子,但徒劳无功。

2 个答案:

答案 0 :(得分:1)

您的要求是否排除使用内置的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"打印机取决于正在使用的操作系统。 (这基本上是对现有驱动程序的捎带)。

  4. ...的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只是文字说......
    2. enter image description here

      代码使用是......

      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 ...
      2.   

        dw_report.SaveAs(&#34;&#34;,PDF!,true)

答案 1 :(得分:0)

现在,Appeon公司已经接管了PowerBuilder的开发,他们计划在下一个版本中融入原生pdf生成(PowerBuilder 2017 - 将于2017年第二季度结束)。目前没有办法从PowerBuilder创建pdf文件而没有额外的软件(无论是Ghostscript还是别的东西)。您可以创建一个COM dll(通过.Net或whatnot)来执行此操作,但它仍然是您需要使用PowerBuilder分发的单独软件