前面我们介绍了如何使用Spire.Presentation 提供的 PresentationPrintDocument 对象打印 PowerPoint 文档,该文将详细介绍如何使用PrinterSettings 对象打印幻灯片文档并进行打印设置。
首先请查看Microsoft PowerPoint打印设置:
C#
static void Main(string[] args)
{
//加载示例文档
Presentation ppt = new Presentation();
ppt.LoadFromFile("Sample.pptx");
//使用 PrinterSettings 对象打印幻灯片
PrinterSettings ps = new PrinterSettings();
ps.PrintRange = PrintRange.AllPages;
ps.PrintToFile = true;
ps.PrintFileName = ("Print.xps");
//打印时幻灯片加框
ppt.SlideFrameForPrint = true;
//灰度打印
ppt.GrayLevelForPrint = true;
//每四张幻灯片打印到一页
ppt.SlideCountPerPageForPrint = PageSlideCount.Four;
//设置打印方向
ppt.OrderForPrint = Order.Horizontal;
////打印不连续页面
//ppt.SelectSlidesForPrint("1", "3");
//打印
ppt.Print(ps);
}
VB.NET
Private Shared Sub Main(args As String())
'加载示例文档
Dim ppt As New Presentation()
ppt.LoadFromFile("Sample.pptx")
'使用 PrinterSettings 对象打印幻灯片
Dim ps As New PrinterSettings()
ps.PrintRange = PrintRange.AllPages
ps.PrintToFile = True
ps.PrintFileName = ("Print.xps")
'打印时幻灯片加框
ppt.SlideFrameForPrint = True
'灰度打印
ppt.GrayLevelForPrint = True
'每四张幻灯片打印到一页
ppt.SlideCountPerPageForPrint = PageSlideCount.Four
'设置打印方向
ppt.OrderForPrint = Order.Horizontal
'''/打印不连续页面
'ppt.SelectSlidesForPrint("1", "3");
'打印
ppt.Print(ps)
End Sub