如何以编程方式打印到PDF文件,而不使用Windows 10附带的Microsof
发布时间:2020-12-13 19:25:19 所属栏目:Windows 来源:网络整理
导读:Microsoft Windows 10附带了一个可打印PDF文件的Microsoft Print To PDF打印机.它提示文件名下载. 我如何以编程方式控制这个从C#不提示PDF文件名,但保存到我提供的某个文件夹中的特定文件名? 这是用于批量处理以编程方式将大量文档或其他类型的文件打印到PD
Microsoft
Windows 10附带了一个可打印PDF文件的Microsoft Print To PDF打印机.它提示文件名下载.
我如何以编程方式控制这个从C#不提示PDF文件名,但保存到我提供的某个文件夹中的特定文件名? 这是用于批量处理以编程方式将大量文档或其他类型的文件打印到PDF.
要使用Microsoft Print to PDF打印机打印PrintDocument对象,而不提示文件名,以下是纯代码方法:
// generate a file name as the current date/time in unix timestamp format file = (string)(DateTime.UtcNow.Subtract(new DateTime(1970,1,1))).TotalSeconds.ToString(); // the directory to store the output. directory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); // initialize PrintDocument object PrintDocument doc = new PrintDocument() { PrinterSettings = new PrinterSettings() { // set the printer to 'Microsoft Print to PDF' PrinterName = "Microsoft Print to PDF",// tell the object this document will print to file PrintToFile = true,// set the filename to whatever you like (full path) PrintFileName = Path.Combine(directory,file + ".pdf"),}; } doc.Print(); 您还可以将此方法用于其他另存为文件类型的方法,如Microsoft XPS打印机 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- jboss7.x – 无法登录到windows上的jboss 7.1管理控制台
- winforms – 如何用DevExpress取代已经消失的60个免费控件?
- Windows 2008 IIS 7 ASP.NET 写入 Event Log 发生 安全性例
- windows – 在Rmd文件中包含apsrtable(或stargazer)输出
- 从MSI安装程序中删除修复选项屏幕
- windows-phone-7 – 适用于Windows Phone 7的中继器或类似设
- windows – USB Stick上的Adobe Air App EXE
- windows – ionic 2启动失败,生成命令出错
- JsonRequestBehavior不存在问题,JsonRequestBehavior属于哪
- windows下z3安装
推荐文章
站长推荐
- active-directory – 阻止EXE在XP域环境中执行
- powershell – 如何将vhd转换为wim文件?
- Windows服务 – Windows服务或计划任务,我们喜欢
- 在Windows批处理中回显UTF-8字符
- 作为Windows服务运行时,Tomcat 7控制台和/或托盘
- Windows上的nginx:bind()到0.0.0.0:80失败
- 视频 – Windows Media Foundation使用IMFTransf
- windows-server-2008 – Windows Server备份D:卷
- exchange-2013 – 关于Microsoft Exchange 2013
- iis-7.5 – IIS 7.5:如何使用Windows身份验证配
热点阅读