2013-03-11 88 views

回答

2

我认为这可能是解决方案:

http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.dc00844_1150/html/pbug/pbug526.htm

关键的变化是,你需要创建自己的打印机不使用GhostScript的文件比附带的Adobe文件。

我认为你应该以这种方式创建的Adobe PDF打印机:

http://www.ehow.com/how_5782035_add-adobe-pdf-printer.html

所以,你应该添加本地打印机使用本文件:

C:\ Program Files文件\ Adobe \ Acrobat 9.0 \ Acrobat \ Xtras \ Adob​​ePDF“点击 ”AdobePDF.inf“

t他的代码应该类似于以下内容:

int li_ret 

dw_1.Object.DataWindow.Export.PDF.Method = Distill! 
dw_1.Object.DataWindow.Printer = "YourAdobePDFPrinterName" 
dw_1.Object.DataWindow.Export.PDF.Distill.CustomPostScript="Yes" 

li_ret = dw_1.SaveAs("custom.PDF", PDF!, true) 

当然,打印还有许多其他问题。随意问!

溴.:的Gabor

+0

我执行了上述所有步骤,并通过重命名可执行文件和dll来禁用我的开发机器上的ghostscript。我得到了一个-1作为saveas()的返回值。一旦我将ghostscript文件重命名为原来的名称,并执行了saveas(),但它没有使用adobe writer,而是使用ghostscript蒸馏器。就好像Powerbuilder明确地寻找Ghostscript,即使我改变了上面的列表的代码。 – 2013-03-12 13:42:01

1

另存为()函数依赖于使用的Ghostscript,使用Adobe Acrobat进行打印,你把它当作一个普通的打印机。希望PB 9具有这些功能,因为它取自PB 11.5。

RegistrySet("HKEY_CURRENT_USER\Software\Adobe\Acrobat Distiller\9.0\AdobePDFOutputFolder", "", ReguLong!, 2) 
RegistrySet("HKEY_CURRENT_USER\Software\Adobe\Acrobat Distiller\9.0\AdobePDFOutputFolder", "2", RegString!, "C:\_APPS") 

//Gets the default printer 
ls_default = PrintGetPrinter() 

//Parses string 
ll_pos = Pos(ls_default, "~t") 
is_default_printer = Left(ls_default, ll_pos - 1) 

//Gets the Printers on the computer 
ls_printers = PrintGetPrinters() 

//Finds the Distiller printer 
ll_pos = PosA(ls_printers, "Acrobat Distiller") 

//Checks for newer version of Distiller 
if (ll_pos = 0) then 
    ll_pos = PosA(ls_printers, "Adobe PDF") 
end if 

//Gets the location of the Distiller printer 
ls_printer = MidA(ls_printers, ll_pos, PosA(ls_printers, ":", ll_pos) - ll_pos + 1) 

//Sets our next print ll_job to print to Distiller 
PrintSetPrinter(ls_printer) 

//Allocates memory for our DS 
DS = create DataStore 

//Opens Print Job 
ll_job = PrintOpen("MyPDF", false) 

//Checks for error 
if (ll_job > 0) then 

//First Datastore to add to the PDF 
DS.DataObject = "d_wlcp_view" 
DS.SetTransObject(SQLCA) 
DS.Retrieve(idt_review_date, ii_site_id) 
PrintDataWindow(ll_job, DS) 

//You can add more pages to the PDF by printing more DW's or DS's 
DS.DataObject = "d_training_view" 
DS.SetTransObject(SQLCA) 
DS.Retrieve(idt_review_date, ii_site_id) 
PrintDataWindow(ll_job, DS) 

//Closes the print job 
PrintClose(ll_job) 

//Sets the default printer back 
PrintSetPrinter(ls_default) 

//Sometimes the PB function doesn't set the printer back, so you can use 
//this VB script to make sure it is set back to the default 
//Run('cscript C:\_APPS\HWLCPRR\prnmngr.vbs -t -p "' + is_default_printer + '"') 

//Deallocates memory for DS 
if (isValid(DS)) then destroy DS 

Here is the VB Script

+0

在我尝试这个之前,我试图将数据窗口保存为pdf文档,以便我可以通过电子邮件发送。这会做到吗? – 2013-03-12 16:29:25

+0

我试过了,它确实创建了pdf文件。我希望该文件自动转到我在代码中提供的文件夹中。有什么办法可以动态设置adobe pdf打印机的默认文件夹吗?用户可以从出现的对话框中做到这一点,但用户无法知道该文档应该放在哪里。 – 2013-03-12 17:03:00

+0

请参阅我的修改后的脚本,查看顶部的两行新代码。当然,根据您使用的Acrobat版本,注册表项会有所不同,因此您可以检查注册表以查找正确的文件夹。另外,如果您的用户使用Acrobat作为他们的打印机之一来创建自己的PDF,那么您可能需要添加其他代码以保存默认设置,然后将其重新设置为该设置。 – 2013-03-12 22:41:45