- 打印 PowerPoint 演示文稿
- 使用特定打印机打印 PowerPoint 演示文稿
- 动态设置 PowerPoint 打印选项
为了打印 PowerPoint 演示文稿,我们将使用Aspose.Slides for .NET,它是一种演示操作 API,可让您从 .NET 应用程序中创建、修改和转换 PowerPoint 演示。
>>你可以点击这里下载Aspose.Slides 最新版测试体验。
使用 C# 打印 PowerPoint 演示文稿
以下是使用 C# 使用默认打印机打印 PowerPoint 演示文稿的步骤。
- 创建Presentation 类的实例 以加载 PowerPoint 演示文稿。
- 调用 Presentation.Print()方法打印演示文稿。
下面的代码示例展示了如何打印 PowerPoint 演示文稿。
// Load the presentationPresentation presentation = new Presentation("presentation.pptx");// Call the print method to print whole presentation with the default printerpresentation.Print();
使用特定打印机打印 PowerPoint 演示文稿
还可以指定打印机名称以打印 PowerPoint 演示文稿。以下是使用特定打印机打印演示文稿的步骤。
- 使用Presentation类加载 PowerPoint 演示 文稿。
- 调用 Presentation.Print(string)方法并将打印机名称作为其参数传递。
以下代码示例展示了如何使用特定打印机打印 PowerPoint 演示文稿。
try{ // Load the presentation Presentation presentation = new Presentation("presentation.pptx"); // Call the print method to print whole presentation to the desired printer presentation.Print("Please set your printer name here");}catch (Exception ex){ Console.WriteLine(ex.Message + "nPlease set printer name as string parameter.");}
动态设置 PowerPoint 打印选项
还可以设置其他打印选项,例如份数、页边距、页面方向等。以下是为 PowerPoint 演示文稿设置不同打印选项的步骤。
- 使用Presentation类加载 PowerPoint 演示 文稿。
-
创建PrinterSettings类的实例并设置所需的选项,例如:
- PrinterSettings.Copies设置份数,
- PrinterSettings.DefaultPageSettings.Landscape以横向打印幻灯片,
- 调用 Presentation.Print(PrinterSettings)方法并将 PrinterSettings 对象作为其参数传递。
下面的代码示例展示了如何设置不同的选项来打印 PowerPoint 演示文稿。
// Load the PowerPoint presentationusing (Presentation pres = new Presentation()){ // Create an object of PrinterSettings and set desired optionsPrinterSettings printerSettings = new PrinterSettings();printerSettings.Copies = 2;printerSettings.DefaultPageSettings.Landscape = true;printerSettings.DefaultPageSettings.Margins.Left = 10;//...etc // Print presentationpres.Print(printerSettings);}
如果你想试用Aspose的全部完整功能,可联系在线客服获取30天临时授权体验。
还想要更多吗可以点击阅读【Aspose最新资源在线文库】,查找需要的教程资源。如果您有任何疑问或需求,请随时加入Aspose技术交流群(),我们很高兴为您提供查询和咨询。
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!