翻譯|使用教程|編輯:李顯亮|2021-08-12 11:09:04.120|閱讀 231 次
概述:通常,可能需要從 Web 或桌面應(yīng)用程序以編程方式打印 PowerPoint 演示文稿。為了實(shí)現(xiàn)它,本文介紹了如何使用 C# 打印 PowerPoint 演示文稿。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
通常,可能需要從 Web 或桌面應(yīng)用程序以編程方式打印 PowerPoint 演示文稿。為了實(shí)現(xiàn)它,本文介紹了如何使用 C# 打印 PowerPoint 演示文稿。此外,您還將學(xué)習(xí)如何動態(tài)設(shè)置所需的打印機(jī)和其他打印選項(xiàng)。
為了打印 PowerPoint 演示文稿,我們將使用Aspose.Slides for .NET,它是一種演示操作 API,可讓您從 .NET 應(yīng)用程序中創(chuàng)建、修改和轉(zhuǎn)換 PowerPoint 演示。
>>你可以點(diǎn)擊這里下載Aspose.Slides 最新版測試體驗(yàn)。
以下是使用 C# 使用默認(rèn)打印機(jī)打印 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();
還可以指定打印機(jī)名稱以打印 PowerPoint 演示文稿。以下是使用特定打印機(jī)打印演示文稿的步驟。
以下代碼示例展示了如何使用特定打印機(jī)打印 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."); }
還可以設(shè)置其他打印選項(xiàng),例如份數(shù)、頁邊距、頁面方向等。以下是為 PowerPoint 演示文稿設(shè)置不同打印選項(xiàng)的步驟。
下面的代碼示例展示了如何設(shè)置不同的選項(xiàng)來打印 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的全部完整功能,可聯(lián)系在線客服獲取30天臨時(shí)授權(quán)體驗(yàn)。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn