Spire.Presentation 支持多种 PowerPoint 文档打印方式,本文将介绍如何使用 Spire.Presentation 提供的 PresentationPrintDocument 对象打印 PowerPoint 文档的三种常见方式:
- 使用默认打印机打印PowerPoint 文档.
- 使用虚拟打印机(Microsoft XPS Document Writer)打印PowerPoint 文档.
- 设置打印页码范围,份数和打印PowerPoint时的显示名称
使用默认打印机打印PowerPoint 文档的所有页面
C#
Presentation ppt = new Presentation();
ppt.LoadFromFile("Sample.pptx");
PresentationPrintDocument document = new PresentationPrintDocument(ppt);
document.PrintController = new StandardPrintController();
ppt.Print(document);
VB.NET
Dim ppt As New Presentation()
ppt.LoadFromFile("Sample.pptx")
Dim document As New PresentationPrintDocument(ppt)
document.PrintController = New StandardPrintController()
ppt.Print(document)
使用虚拟打印机(Microsoft XPS Document Writer)打印PowerPoint 文档
C#
Presentation ppt = new Presentation();
ppt.LoadFromFile("Sample.pptx");
PresentationPrintDocument document = new PresentationPrintDocument(ppt);
document.PrinterSettings.PrinterName = "Microsoft XPS Document Writer";
ppt.Print(document);
VB.NET
Dim ppt As New Presentation()
ppt.LoadFromFile("Sample.pptx")
Dim document As New PresentationPrintDocument(ppt)
document.PrinterSettings.PrinterName = "Microsoft XPS Document Writer"
ppt.Print(document)
设置打印页码范围,份数和打印PowerPoint时的显示名称
C#
Presentation ppt = new Presentation();
ppt.LoadFromFile("Sample.pptx");
PresentationPrintDocument document = new PresentationPrintDocument(ppt);
//设置打印过程中的显示名称
document.DocumentName = "展示报表部分打印";
//设置打印页码范围
document.PrinterSettings.PrintRange = PrintRange.SomePages;
document.PrinterSettings.FromPage = 1;
document.PrinterSettings.ToPage = 2;
//设置打印份数
document.PrinterSettings.Copies = 2;
ppt.Print(document);
VB.NET
Dim ppt As New Presentation()
ppt.LoadFromFile("Sample.pptx")
Dim document As New PresentationPrintDocument(ppt)
'设置打印过程中的显示名称
document.DocumentName = "展示报表部分打印"
'设置打印页码范围
document.PrinterSettings.PrintRange = PrintRange.SomePages
document.PrinterSettings.FromPage = 1
document.PrinterSettings.ToPage = 2
'设置打印份数
document.PrinterSettings.Copies = 2
ppt.Print(document)