翻譯|使用教程|編輯:李顯亮|2021-08-12 11:09:04.120|閱讀 231 次
概述:通常,可能需要從 Web 或桌面應用程序以編程方式打印 PowerPoint 演示文稿。為了實現它,本文介紹了如何使用 C# 打印 PowerPoint 演示文稿。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
通常,可能需要從 Web 或桌面應用程序以編程方式打印 PowerPoint 演示文稿。為了實現它,本文介紹了如何使用 C# 打印 PowerPoint 演示文稿。此外,您還將學習如何動態設置所需的打印機和其他打印選項。
為了打印 PowerPoint 演示文稿,我們將使用Aspose.Slides for .NET,它是一種演示操作 API,可讓您從 .NET 應用程序中創建、修改和轉換 PowerPoint 演示。
>>你可以點擊這里下載Aspose.Slides 最新版測試體驗。
以下是使用 C# 使用默認打印機打印 PowerPoint 演示文稿的步驟。
下面的代碼示例展示了如何打印 PowerPoint 演示文稿。
// Load the presentation Presentation presentation = new Presentation("presentation.pptx"); // Call the print method to print whole presentation with the default printer presentation.Print();
還可以指定打印機名稱以打印 PowerPoint 演示文稿。以下是使用特定打印機打印演示文稿的步驟。
以下代碼示例展示了如何使用特定打印機打印 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 演示文稿。
// Load the PowerPoint presentation using (Presentation pres = new Presentation()) { // Create an object of PrinterSettings and set desired options PrinterSettings printerSettings = new PrinterSettings(); printerSettings.Copies = 2; printerSettings.DefaultPageSettings.Landscape = true; printerSettings.DefaultPageSettings.Margins.Left = 10; //...etc // Print presentation pres.Print(printerSettings); }
如果你想試用Aspose的全部完整功能,可聯系在線客服獲取30天臨時授權體驗。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn