下面两种导出PDF的方法的前提是都必须按照虚拟打印机(按照福昕和Adobe会自动安装虚拟打印机)

/////////////////////////////////////////福昕虚拟打印机导出PDF/////////////////////////////////////////////////////////

tab_1.tabpage_3.dw_2.object.datawindow.print.DocumentName="bbb.pdf"
tab_1.tabpage_3.dw_2.object.datawindow.printer="Foxit Phantom Printer" //"Foxit Rreader PDF Printer"

li_i=tab_1.tabpage_3.dw_2.print()
messagebox('ts',String(li_i))

///////////////////////////////////////AdobePDF虚拟打印机导出PDF//////////////////////////////////////////////////////////
long li_i,al_id,ll_row
DateTime pfinishdate,createdate,lasteditdate
al_id=1
Long i,row_coun

ll_row=PARENT.tab_1.tabpage_1.dw_head.getrow()
al_id=PARENT.tab_1.tabpage_1.dw_head.object.FSO_CONTRACTID[ll_row]

String pono,bcontact,btel,ownername,mobile1,custno,salename,txmobile,custlevelno,cityname,xfcityname,remark,mark,side_mark,side_mark2
String companyname,briefname
String index_code,custitemno,lpackqty,BOXQTY,purqty,productid,packmemo,pfinishdate_zb
decimal{6} purprice
blob lblb_data

n_cst_print lnv_print


tab_1.tabpage_3.dw_2.DataObject = "d_sales_popup_head"
tab_1.tabpage_3.dw_2.Reset()

datawindowchild dwc[2]
tab_1.tabpage_3.dw_2.getchild("dw_1",dwc[1])
tab_1.tabpage_3.dw_2.getchild("dw_2",dwc[2])


Select pono,
pfinishdate,
createdate,
lasteditdate,
bcontact,
NVL(BTEL,' ')||'/'||NVL(CUSTFAX,' ') btel,
ownername,
NVL(MOBILE1,' ')||'/'||NVL(HOME_TEL1,' ')||'/'||NVL(HOME_TEL2,' ') mobile1,
custno,
salename,
txmobile ,
custlevelno,
cityname,
xfcityname,
REPLACE(REPLACE(REPLACE(remark,' ',' '),'!','!'),'"',' ') ,// REPLACE(REPLACE(REPLACE(REPLACE(remark,' ',' '),'!','!'),'''',' '),'"',' ') ,
REPLACE(REPLACE(REPLACE(mark,' ',' '),'!','!'),'"',' ') , //TAB键值转入TEXT属性中时报错,将TAB键值替换成4个空格
REPLACE(REPLACE(REPLACE(side_mark,' ',' '),'!','!'),'"',' ') ,
REPLACE(REPLACE(REPLACE(side_mark2,' ',' '),'!','!'),'"',' ') ,
companyname,
briefname
Into :pono,
:pfinishdate,
:createdate,
:lasteditdate,
:bcontact,
:btel,
:ownername,
:mobile1,
:custno,
:salename,
:txmobile,
:custlevelno,
:cityname,
:xfcityname,
:remark,
:mark,
:side_mark,
:side_mark2,
:companyname,
:briefname
From PROJECTED_SALES_CONTRACT Where FSO_CONTRACTID = :al_id;

//select REPLACE(REPLACE(REPLACE(:remark,' ',' '),'!','!'),'',' '),REPLACE(:mark,' ',' '),REPLACE(:side_mark,' ',' '),REPLACE(:side_mark2,' ',' ') into :remark,:mark,:side_mark,:side_mark2 from dual;
/*
dwc[1].Modify("t_pfinishdate.Text="+" '"+String(pfinishdate,'yyyy-mm-dd')+"' ")
dwc[1].Modify("t_lasteditdate.Text="+" '"+String(lasteditdate,'yyyy-mm-dd hh-mm-ss')+"' ")
dwc[1].Modify("t_createdate.Text="+" '"+String(pfinishdate,'yyyy-mm-dd')+"' ")
dwc[1].Modify("t_pono.Text="+" '"+pono+"' ")
dwc[1].Modify("t_pono1.Text="+" '"+pono+"' ")
dwc[1].Modify("t_bcontact.Text="+" '"+bcontact+"' ")
dwc[1].Modify("t_btel.Text="+" '"+btel+"' ")
dwc[1].Modify("t_ownername.Text="+" '"+ownername+"' ")
dwc[1].Modify("t_mobile1.Text="+" '"+mobile1+"' ")
dwc[1].Modify("t_custno.Text="+" '"+custno+"' ")
dwc[1].Modify("t_salename.Text="+" '"+salename+"' ")
dwc[1].Modify("t_txmobile.Text="+" '"+txmobile+"' ")
dwc[1].Modify("t_custlevelno.Text="+" '"+custlevelno+"' ")
dwc[1].Modify("t_cityname.Text="+" '"+cityname+"' ")
dwc[1].Modify("t_xfcityname.Text="+" '"+xfcityname+"' ")
*/

dwc[2].Modify("t_remark.Text="+" '"+remark+"' ")
dwc[2].Modify("t_mt1.Text="+" '"+mark+"' ")
dwc[2].Modify("t_mt2.Text="+" '"+side_mark+"' ")
dwc[2].Modify("t_mt3.Text="+" '"+side_mark2+"' ")
dwc[2].Modify("t_companyname.Text="+" '"+companyname+"' ")
dwc[2].Modify("t_provfname.Text="+" '"+briefname+"' ")

Declare get_bill Cursor For
Select '序号:'||to_char(ORDERNO) index_code,
custitemno,
to_char(nvl(LPACKQTY,0))||'/'||to_char(nvl(UNITBOXQTY,0)) lpackqty,
BOXQTY,
TO_CHAR(NVL(purqty,0))||UNIT AS purqty,
//purprice,
itemno,
'材料工艺说明:'||nvl(DTCUSTOMFIELD11,' ')|| chr(13)||chr(10) || chr(13)||chr(10) ||'颜色说明:'||nvl(DTCUSTOMFIELD12,' ')
|| chr(13)||chr(10) || chr(13)||chr(10) ||'包装说明:'||nvl(PACKMEMO,' ')|| chr(13)||chr(10) || chr(13)||chr(10) ||'装箱说明:'||NVL(STUFFMEMO,' ')
|| chr(13)||chr(10) || chr(13)||chr(10) ||'跟单补充说明:'||NVL(SUPPLEMENTMEMO,' ')
|| chr(13)||chr(10) || chr(13)||chr(10) ||'品质/测试说明:'|| chr(13)||chr(10) ||NVL(TRAITMEMO,' ') || chr(13)||chr(10) ||'返单说明:'||NVL(REORDERNO,' ') packmemo,
to_char(PFINISHDATE,'yyyy-mm-dd') as PFINISHDATE
From PROJECTED_CONTRACT_DETAIL a
Where a.FSO_CONTRACTID= :al_id
Order By a.orderno;

Open get_bill;
Do While 1 = 1
Fetch get_bill Into :index_code,
:custitemno,
:lpackqty,
:BOXQTY,
:purqty,
//:purprice,
:productid,
:packmemo,
:pfinishdate_zb;
If sqlca.SQLCode = 0 Then

i = dwc[2].InsertRow(0)
dwc[2].setItem(i,"index_code",index_code)
dwc[2].setItem(i,"custitemno",custitemno)
dwc[2].setItem(i,"lpackqty",lpackqty)
dwc[2].setItem(i,"BOXQTY",BOXQTY)
dwc[2].setItem(i,"purqty",purqty)
dwc[2].setItem(i,"purprice",purprice)
dwc[2].setItem(i,"productid",productid)
dwc[2].setItem(i,"packmemo",packmemo)
dwc[2].setItem(i,"pfinishdate_zb",pfinishdate_zb)

Else
Exit
End If
Loop
Close get_bill;

Commit;


//int li_ret
//
//string ls_docname, ls_named
//
//integer li_value
//
//li_value = GetFileSaveName( "选择保存文件 ", ls_docname, ls_named, "PDF文件", "PDF文件 (*.PDF),*.PDF ")
//
//
//IF li_value <> 1 THEN Return
//
//tab_1.tabpage_3.dw_2.Object.DataWindow.Export.PDF.Method = Distill!
//
// //选择虚拟打印机
//
//tab_1.tabpage_3.dw_2.Object.DataWindow.Printer = "Adobe PDF"// "Adobe PDF" // "Acrobat Distiller "
//
////tab_1.tabpage_3.dw_2.Object.DataWindow.Export.PDF.Distill.CustomPostScript= "Yes "
//
//li_ret = tab_1.tabpage_3.dw_2.SaveAs(ls_docname, pdf!, TRUE)
//
//IF li_ret = 1 Then
//
//MessageBox( '提示信息 ', '保存为PDF文件成功!~r~n文件为: ' + ls_docname)
//
//Else
//
//MessageBox( '提示信息 ', '保存为PDF文件失败! '+String(li_ret))
//
//End IF
//

dwc[1].settransobject( sqlca )
dwc[1].retrieve( 1 )

//inv_Print.of_Print_View(tab_1.tabpage_3.dw_2) //打印


int li_ret
String ls_filename
ls_filename="D:\FileIO"
//GetCurrentDirectory() //获取当前软件的安装目录
if not DirectoryExists(ls_filename) then //判断文件夹是否存在,如果不存在则创建
li_ret=CreateDirectory(ls_filename) //创建文件夹
if li_ret<>1 then
MessageBox( '提示信息 ', '创建文件夹失败,请在D盘创建 FileIO 文件夹!' )
return;
end if
end if

ls_filename=ls_filename+"\"+PONO
tab_1.tabpage_3.dw_2.Object.DataWindow.Export.PDF.Method = Distill!
tab_1.tabpage_3.dw_2.Object.DataWindow.Export.PDF.Distill.CustomPostScript = 'Yes'
tab_1.tabpage_3.dw_2.object.datawindow.print.DocumentName=ls_filename
tab_1.tabpage_3.dw_2.object.datawindow.printer="Adobe PDF"
li_ret=tab_1.tabpage_3.dw_2.print()
IF li_ret = 1 Then

MessageBox( '提示信息 ', '保存为PDF文件成功!' )

Else

MessageBox( '提示信息 ', '保存为PDF文件失败! ')

End IF

下面的图片为PDF配置:

注:路径必须为D:\FileIO