# Python 表单插件 代码如下
import clr
clr.AddReference("mscorlib")
clr.AddReference("System")
clr.AddReference("Kingdee.BOS")
clr.AddReference("Kingdee.BOS.Core")
clr.AddReference("Kingdee.BOS.App")
clr.AddReference("System.Data")
clr.AddReference("Kingdee.BOS.App.Core")
clr.AddReference("Kingdee.BOS.ServiceHelper")
from Kingdee.BOS import *
from Kingdee.BOS.App.Data import *
from Kingdee.BOS.Core.DynamicForm.PlugIn import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import *
from Kingdee.BOS.Util import *
from Kingdee.BOS.App.Core import *
from Kingdee.BOS.ServiceHelper import *
from Kingdee.BOS.Core.Metadata.StatusElement import ExportPdfItem
from Kingdee.BOS.Core.NotePrint import PrintExportInfo
from Kingdee.BOS.Core.NotePrint import ExportFileType
from Kingdee.BOS.Core.NotePrint import ExportType
from Kingdee.BOS.Core.NotePrint import ViewPrintUtils
from System import *
from System.Collections.Generic import *
from System.Data import *
def BarItemClick(e):
if e.BarItemKey == "tbSplitSave":#保存按钮触发
datenow=(DateTime.Now.ToString("yyyyMMddHHssfff"));
viewServer=this.View;
Fids = List[str]();
Template = List[str]();
Fids.Add(str(this.View.Model.DataObject["Id"]));
Template.Add(str("36bd479f-7890-4898-861a-509ee474bf60")); #套打模板标识
parentView = this.View.ParentFormView;
pexport = PrintExportInfo();
ids=parentView.PageId;
pexport.PageId=(parentView.PageId);
pexport.FormId=("PUR_PurchaseOrder"); #表单FormId
pexport.BillIds=(Fids);#单据Fid
pexport.TemplateIds=(Template);#套打模板标识
pexport.FileType = ExportFileType.PDF;#导出文件格式
pexport.ExportType = ExportType.Merge;#导出文件类型
pexport.ExportFileName = ("采购订单" + str(datenow) + ".Pdf");#文件名,注意文件名不能出现":"冒号
pexport.FilePath=("D:\\"+ pexport.ExportFileName);#输出路径,注意路径不能重复出现":"冒号
#pexport.ExportToSingleFile = True;#导出到同一个文件
FPdf=pexport;
viewServer.ExportNotePrint(pexport);#调用导出
this.View.ShowMessage(str(FPdf.FilePath));
#获取套打标识:
推荐阅读