通过C#实现中望CAD的运行中静默打印PDF功能。可以自定义具体打印设备名称、纸张类型、打印样式表、打印范围、着色打印类型等;将using中的“ZwSoft.ZwCAD”改为“Autodesk.AutoCAD”可以应用在AutoCAD开发中。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZwSoft.ZwCAD.ApplicationServices;
using ZwSoft.ZwCAD.DatabaseServices;
using ZwSoft.ZwCAD.PlottingServices;
using ZwSoft.ZwCAD.Runtime;namespace ZWCADTest_48
{public class PrintTest{[CommandMethod("PrintToPDF")]public void PrintToPDF(){Document acDoc = Application.DocumentManager.MdiActiveDocument;Database acDb = acDoc.Database;// 打印结果文件的输出路径string outputName = @"D:\CAD\PrintPDF\MyFile.pdf";// 打印机名称:ZWCAD PDF(High Quality Print).pc5string deviceName = "ZWCAD PDF(High Quality Print).pc5";// 纸张:"ISO_full_bleed_A0_(841.00_x_1189.00_MM)"string canonicalMediaName = "ISO_full_bleed_A0_(841.00_x_1189.00_MM)";// 打印样式表:zwcad.ctbstring styleSheetName = "zwcad.ctb";// PlotSettings.PlotType 打印范围:范围 Extents// PlotSettings.ShadePlot 着色打印:按显示 AsDisplayed  using (Transaction tr = acDb.TransactionManager.StartTransaction()){// 获取打印机配置PlotConfig plotConfig = PlotConfigManager.SetCurrentConfig(deviceName);plotConfig.RefreshMediaNameList();// 将打印机的PlotToFile属性设置为trueplotConfig.IsPlotToFile = true;PlotSettings plotSettings = new PlotSettings(true);PlotSettingsValidator plotSettingsValidator = PlotSettingsValidator.Current;// 配置打印设置和打印信息plotSettingsValidator.SetUseStandardScale(plotSettings, true);plotSettingsValidator.SetStdScaleType(plotSettings, StdScaleType.ScaleToFit);plotSettingsValidator.SetPlotCentered(plotSettings, true);plotSettingsValidator.SetPlotRotation(plotSettings, PlotRotation.Degrees000);// 设置设备名称和图纸名称plotSettingsValidator.SetPlotConfigurationName(plotSettings, deviceName, canonicalMediaName);// 设置打印样式表plotSettingsValidator.SetCurrentStyleSheet(plotSettings, styleSheetName);// 设置打印范围plotSettingsValidator.SetPlotType(plotSettings, ZwSoft.ZwCAD.DatabaseServices.PlotType.Extents);// 设置着色打印选项plotSettings.ShadePlot = PlotSettingsShadePlotType.AsDisplayed;//验证打印信息PlotInfoPlotInfoValidator plotInfoValidator = new PlotInfoValidator();PlotInfo plotInfo = new PlotInfo();LayoutManager manager = LayoutManager.Current;Layout layout = tr.GetObject(manager.GetLayoutId(manager.CurrentLayout), OpenMode.ForRead) as Layout;plotInfo.Layout = layout.ObjectId;plotInfo.OverrideSettings = plotSettings;plotInfo.DeviceOverride = plotConfig;plotInfo.ValidatedConfig = plotConfig;plotInfoValidator.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;plotInfoValidator.Validate(plotInfo);// 使用PlotEngine对象开始打印using (PlotEngine plotEngine = PlotFactory.CreatePublishEngine()){// 执行打印操作plotEngine.BeginPlot(null, null);plotEngine.BeginDocument(plotInfo, acDoc.Name, null, 1, true, outputName);PlotPageInfo pageInfo = new PlotPageInfo();plotEngine.BeginPage(pageInfo, plotInfo, true, null);plotEngine.BeginGenerateGraphics(null);plotEngine.EndGenerateGraphics(null);plotEngine.EndPage(null);plotEngine.EndDocument(null);plotEngine.EndPlot(null);}}}}
}

C# 中望CAD(AutoCAD 非Com方式)打印PDF相关推荐

  1. 使用PDF处理控件Aspose.PDF以编程方式打印PDF文档完整攻略

    许多公司在很大程度上减少了纸张的使用.但是,在某些情况下打印很重要.例如,系统可能包含PDF格式的在线订单的详细信息.他们需要在分发在线订单进行交付时打印PDF.他们大规模处理项目,因此手动打印每个文 ...

  2. 利用Aspose.PDF以编程方式打印PDF文档

    使用C#打印PDF文件 可以使用C#或VB.net在.NET应用程序中自动打印PDF文件.您可以按照以下简单步骤打印PDF文件: 创建一个PdfViewer类的对象 加载输入的PDF文档 打印PDF文 ...

  3. 中序遍历二叉树-非递归方式实现-附C++代码

    一.问题描述 给定一个二叉树,要求以非递归的方式进行中序遍历. 原题:二叉树的中序遍历 - leetcode 二.解题思路 首先需要知道一些前置知识:中序遍历是指按 左子树 -> 根节点 -&g ...

  4. 中望CAD图纸的单页和批量pdf打印方式

    1 单页打印 1.1 选择打印 1.2 选择pdf打印机,并点击选择打印区域 1.3 在窗口中框选打印区域 1.4 框选完毕,跳回到对话框.选择预览,或者直接确定. 1.5 点击"确定&qu ...

  5. 二叉树 —— 创建二叉树 先序遍历 、中序遍历、后序遍历(递归方式、非递归方式)

    #include<stdio.h> #include<malloc.h> #include<stdlib.h> typedef char DataType; #de ...

  6. 分别用递归和非递归方式实现二叉树先序、中序和后序遍历(java实现)

    分别用递归和非递归方式实现二叉树先序.中序和后序遍历 用递归和非递归方式,分别按照二叉树先序.中序和后序打印所有的节点.我们约定:先序遍历顺序 为根.左.右;中序遍历顺序为左.根.右;后序遍历顺序为左 ...

  7. 算法练习day10——190328(二叉树的先序、 中序、 后序遍历, 包括递归方式和非递归方式、找到一个节点的后继节点、二叉树的序列化和反序列化)

    1.实现二叉树的先序. 中序. 后序遍历, 包括递归方式和非递归方式 1.1 访问节点的顺序 节点访问顺序如下图所示: 访问顺序:1 2 4 4 4 2 5 5 5 2 1 3 6 6 6 3 7 7 ...

  8. 左神算法:分别用递归和非递归方式实现二叉树先序、中序和后序遍历(Java版)

    本题来自左神<程序员代码面试指南>"分别用递归和非递归方式实现二叉树先序.中序和后序遍历"题目. 题目 用递归和非递归方式,分别按照二叉树先序.中序和后序打印所有的节点 ...

  9. AUTOCAD——调整十字光标、CAD表格文字对齐方式

    CAD如何调整十字光标? 执行方式 1.输入自定义设置命令"OPTIONS"(快捷键:OP),按下空格键. 自定义设置 2.在弹出的选项界面中,打开显示页面,选择页面中的" ...

最新文章

  1. 在项目中使用Google Closure Compiler
  2. 20135306黄韧 信息安全系统设计基础期中学习总结
  3. 2021吉林市高考成绩查询系统,吉林省教育考试院高考成绩查询系统入口2021
  4. 20180315 代码错题(1)
  5. OpenGL创建一个GLFW窗口的实例
  6. 保护1000万篇原创文章,区块链技术如何做到
  7. NDK编译错误expected specifier-qualifier-list before...
  8. 工厂模式(简单工厂、工厂方法、抽象工厂)
  9. Extjs弹窗-简单文本编辑框-Ext.Msg.show
  10. HDU 5730——Shell Necklace
  11. 前端学习(338):堆栈
  12. 安徽关节式焊接机器人_机器人自动焊接技术的优势及应用介绍
  13. solr使用网页浏览器批量导入数据库中数据(本案例是mysql)
  14. 循环结果添加到集合_Excel VBA 8.4 Python中有集合直接获取唯一值,那Exce中可以吗?...
  15. paip.验证码识别---图像处理类库
  16. php输出图片问题,解决ThinkPHP里无法输出图片问题(关于设置响应头)
  17. Linux开发之libaio源码分析及应用
  18. 有电流平衡能力的6组白光LED驱动器MAX8790
  19. 苹果手机人脸识别不了是什么原因_iPhone和安卓手机的人脸识别有什么区别?
  20. 通过浏览器打开本地exe应用(支持任意浏览器)

热门文章

  1. GitHub仓库私人仓库分享权限
  2. CSDN中的草稿箱在哪里?
  3. 别再被骗了!你以为的大片其实是这样拍出的?
  4. c语言设计李玲玲答案,李玲玲
  5. 已经在此计算机安装版本的,电脑安装iTunes时提示这台电脑已安装了更高版本怎么解决...
  6. 【华为】新版模拟器eNSP Lite实验界面提前解锁
  7. 联想微型计算机c340加内存,联想C340 C345一体机内存硬盘CPU拆卸与升级方法
  8. 升级鸿蒙系统内存,网友实测从安卓升级到鸿蒙 2.0:可用内存和存储容量增加...
  9. speedoffice文档如何查看字数
  10. PhpStorm 中如何配置 PHP 语言的版本