本文主要归纳总结了常见的几种PPT幻灯片文档打印的方法及需求。具体通过C#示例来分别阐述以下几种情况:
一、通过PresentationPrintDocument 对象来打印
二、通过PrinterSettings 对象来设置打印选项并打印
使用工具:Spire.Presentation for .NET
方法1:通过官网下载dll文件包。下载后,解压文件并安装。完成安装后,将安装路径下BIN文件夹中的Spire.Presentation.dll程序集文件添加引用至C#程序。
C#代码示例(供参考)
Presentation ppt = new Presentation(); ppt.LoadFromFile("Sample.pptx"); PresentationPrintDocument document = PresentationPrintDocument(ppt); document.PrintController = StandardPrintController(); ppt.Print(document);
【示例2】使用虚拟打印机(Microsoft XPS Document Writer)打印
Presentation ppt = PresentationPrintDocument(ppt); document.PrinterSettings.PrinterName = Microsoft XPS Document Writer; ppt.Print(document);
Presentation ppt = PresentationPrintDocument(ppt); //设置打印过程中的显示名称 document.DocumentName = 展示报表部分打印; 设置打印页码范围 document.PrinterSettings.PrintRange = PrintRange.somePages; document.PrinterSettings.FromPage = 1; document.PrinterSettings.ToPage = 2设置打印份数 document.PrinterSettings.copies = ; ppt.Print(document);
【示例4】通过PrinterSettings 对象来设置打印选项并打印
加载示例文档 Presentation ppt = ); 使用 PrinterSettings 对象打印幻灯片 PrinterSettings ps = PrinterSettings(); ps.PrintRange = PrintRange.AllPages; ps.PrintToFile = true; ps.PrintFileName = (Print.xps打印时幻灯片加框 ppt.SlideFrameForPrint = 灰度打印 ppt.GrayLevelForPrint = 每四张幻灯片打印到一页 ppt.SlideCountPerPageForPrint = PageSlideCount.Four; 设置打印方向 ppt.OrderForPrint = Order.Horizontal; ////打印不连续页面 ppt.SelectSlidesForPrint("1","3"); 打印 ppt.Print(ps);
(本文完)
转载请注明出处!!