如何导出pdf文件?
-
回答:
主要用到函数说明:
MxDrawXCustomFunction::Mx_ExprotPdf
导出pdf文件,详细说明如下:
参数 说明 CString sPdfFileName
pdf文件路径
double dPaperH = 210
Pdf的图纸高度,该值越大,pdf文件越大,分辨率越高
double dPaperW = 297
Pdf的图纸宽度,该值越大,pdf文件越大,分辨率越高
LPCTSTR pszTitle = NULL
Pdf文件的标题
BOOL isExportLayout = FALSE
是否同时导出DWG图纸的布局页面
BOOL isBlackWhite = FALSE
是否把颜色变成黑白色,再输出
iCountLayout
布局数组长度 LayoutName.. -布局数组的布局名
代码实现如下:
ActiveXComponent smsg1 = new ActiveXComponent("MxDrawX.MxDrawService"); // 获取Active对象 Dispatch msg1 = smsg1.getObject(); // 调用组件方法,打开指定dwg文件 msg1.call(msg1, "Open", "D:/temp/ife/1.dwg"); //msg1.call(msg1, "SaveDwgFile", "D:/temp/ife/1test.pdf"); ActiveXComponent smsg = new ActiveXComponent("MxDrawX.MxDrawApplication"); Dispatch msg = smsg.getObject(); ActiveXComponent paramCom = new ActiveXComponent("MxDrawX.MxDrawResbuf"); Dispatch param3 = paramCom.getObject(); param3.call(param3,"AddString","d:/temp/1test.pdf"); param3.call(param3,"AddDouble",2000); param3.call(param3,"AddDouble",2000); param3.call(param3,"AddString","ife"); param3.call(param3,"AddLong",1); param3.call(param3,"AddLong",0); Object[] params4 = new Object[] {"Mx_ExportPdf",param3}; Dispatch result = msg.call(msg,"CallEx",params4).toDispatch(); Variant aaa=result.call(result, "AtString",0); System.out.println("done. "+aaa); smsg.safeRelease(); msg1.call(msg1, "Close"); smsg1.safeRelease(); paramCom.safeRelease();