如何将pb9数据窗口导出为pdf格式
早就听说pb9支持pdf格式,但是始终没有亲自去体会。直到有任务要写这么一个文档,才有幸去研究一下,和大家分享。
按照网上的说法,还要安装一的工具gs705w32.exe ,兄弟们可以到网上去下载,也可以到我处获得,目前还不收费哦。
1.下载安装gs705w32.exe
网址: http://prdownloads.sourceforge.net/ghostscript/gs705w32.exe?download也可下载安装ghostscript7.06,但pb9不支持gs8.0及其以上版本!
2.针对PowerBuilder9.0 添加入path环境变量 gs705w32.exe 的安装默认路经为c:/gs(可以修改) 添加环境变量path: C:\\gs\\gs7.05\\bin
3.安装虚拟打印机
直接在\控制面板\打印机和传真\添加打印机\,
端口任意,默认的LPT1就可以,反正我们也不是用它做打印功能
关键是驱动的选择,此驱动是PowerBuilder9.0自带的,就在PowerBuilder9.0的安装文件夹下, 选择从\磁盘安装\
此时选择Adobe厂商的inf文件\读取到五个驱动: \ Distiller\
\ Distiller CS\ \ Distiller CT\ \ Distiller J\ \ Distiller K\
选择第一个\ Distiller\其它四个也可以),下一步即可>\安装完毕\
也可以在Sybase\\Shared\\PowerBuilder\\drivers下编辑.BAT文件,写入:
rundll32.exe printui.dll,PrintUIEntry /if /f .\\\\ADIST5.INF /r \ /b \ Distiller\ /m \ Distiller\ 运行它也可实现添加虚拟打印机!
1. 在pb9环境下菜单中使用save row as生成pdf报表:
? 在datawindow的Data Export中属性栏设置Format to configure为PDF 设置Method为Distill!
选中Distill Custom PostScript
? 设置默认打印机为PDF虚拟打印机:
在Printer Setup中选中Acrobat Distiller ... 最后File>save row as>pdf>... 就OK了!!
2. 在代码中利用saveas()生成pdf报表: int li_ret,li_ret2
string ls_docname, ls_named
li_ret2 = GetFileSaveName(\ file\ ls_docname, ls_named, \ file (*.pdf), *.pdf\ )
messagebox(\ = \
//Saving as PDF select the distill method
dw_1.Object.DataWindow.Export.PDF.Method = Distill!
//select printer
dw_1.Object.DataWindow.Printer = \ Distiller\
dw_1.Object.DataWindow.Export.PDF.Distill.CustomPostScript=\
//printing pdf files
IF (li_ret2 = 1) THEN
li_ret = dw_1.SaveAs(ls_docname, PDF!, false) else return end if
if li_ret=1 then
messagebox(\ else
Messagebox('Error','Failed!!!',StopSign!) end if