码迷,mamicode.com
首页 > 其他好文 > 详细

CAD如何直接打印,不出现打印对话框?

时间:2019-06-03 12:53:40      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:ntc   显示   ram   内容   isp   model   custom   space   null   

主要用到函数说明:

 

MxDrawXCustomFunction::Mx_Print

 

直接打印,不出现打印对话框,详细说明如下:

 

参数说明

double ptLBx

打印的范围左下角x

double ptLBy

打印的范围左下角y

double ptRTx

打印的范围右上角x

double ptRTy

打印的范围右上角y

LPCTSTR pszPrintName

打印机名,如果传为空,取系统默认打印机

LPCTSTR pszPaperName

打印的图纸名,如果传为空,取系统默认打印机设置

LONG iPrintDirection

打印的方向,2 为横向,1为纵向,默认取1

LONG iLeftMargin

打印的页边的左边距离,如果为-1,取打印机默认的页边距

LONG iRightMargin

打印的页边的右边距离,如果为-1,取打印机默认的页边距

LONG iTopMargin

打印的页边的上边距离,如果为-1,取打印机默认的页边距

LONG iBottomMargin

打印的页边的下边距离,如果为-1,取打印机默认的页边距

LPCTSTR pszLayoutName

打印的布局,为NULL就是模型Model中的内容

LPCTSTR pszPrintConfig

打印配制,暂没有使用

LPCTSTR pszDocName

打印的文档名称,在用pdf虚拟打印机时,指定打印的pdf文件的缺省文件名

LONG lIsPrintLineWdith

是否打印线宽,默认值为1,表示打印,传0表示不打印

iFlag

pRectPageMargin参数的含义,iFlag = 0表示页边距,iFlag = 1表示打印区域矩形框位置

 

js代码实现如下:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
            function  myprint()
            {
                var axMxDrawX = document.getElementById("MxDrawXCtrl");
                var viewBound  = axMxDrawX.Call("Mx_GetViewCoord","");
 
                var printParam =  axMxDrawX.Call("Mx_NewResbuf","");                
                // 打印范围取当前视区显示内容                
                printParam.AddDouble(viewBound.AtDouble(1));
                printParam.AddDouble(viewBound.AtDouble(2));
                printParam.AddDouble(viewBound.AtDouble(3));
                printParam.AddDouble(viewBound.AtDouble(4));
 
                 var jpgWidth = viewBound.AtDouble(3) - viewBound.AtDouble(1);
                var jpgHeight = viewBound.AtDouble(4) - viewBound.AtDouble(2);                
                // 把jpg的宽度,高度,求文档坐标变成象素宽高.
                //var jpgWidth = axMxDrawX.CallDoubleParam1("Mx_DocLongToViewCoord",jpgWidth);
                // jpgWidth = jpgWidth.AtLong(1);
                //var jpgHeight = axMxDrawX.CallDoubleParam1("Mx_DocLongToViewCoord",jpgHeight);
                //jpgHeight = jpgHeight.AtLong(1);
 
                var printWidth = 50;
                var printHeight = 50;                
                if(jpgWidth > 1)
                    printHeight = printWidth * jpgHeight / jpgWidth;                
                    // 打印机名,取空就取系统默认的。                
                    printParam.AddString("");                
                    // 图纸名,取空就取系统默认的                
                    printParam.AddString("");                
                    // 打印的方向,2 为横向,1为纵向,默认取1
                printParam.AddLong(1);                
                // 打印区域的左上角X坐标,图纸单为mm
                printParam.AddLong(50);                
                // 打印区域的右下角X坐标,图纸单为mm
                printParam.AddLong(50 + printWidth );                
                // 打印区域的左上角Y坐标,图纸单为mm
                printParam.AddLong(50);                
                // 打印区域的右下角Y坐标,图纸单为mm
                printParam.AddLong(50 + printHeight);                
                // 打印的布局,为NULL就是模型Model中的内容
                printParam.AddString("");                
                // 打印配制,暂没有使用
                printParam.AddString("");                
                // 打印的文档名称,在用pdf虚拟打印机时,指定打印的pdf文件的缺省文件名
                printParam.AddString("");                
                // 前面打印参数说明:iFlag = 0表示页边距,iFlag = 1表示打印区域矩形框位置                printParam.AddLong(1);                // 开始打印                var ret = axMxDrawX.CallEx("Mx_Print",printParam);                if(ret.AtString(0) == "Ok")
                    alert("打印成功");
            }

CAD如何直接打印,不出现打印对话框?

标签:ntc   显示   ram   内容   isp   model   custom   space   null   

原文地址:https://www.cnblogs.com/yzy0224/p/10966488.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!