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)