翻譯|使用教程|編輯:李顯亮|2020-02-13 15:46:05.037|閱讀 713 次
概述:為了將PPT/PPTX轉換為PDF,文本將使用Aspose.Slides for .NET,在本文中,將展示一系列功能,以使用C#將PowerPoint PPT無縫轉換為PDF或將PPTX無縫轉換為PDF。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
您是否正在尋找將PowerPoint PPT / PPTX轉換為PDF的可靠而簡單的解決方案?您想將PowerPoint演示文稿準確地高質量轉換為PDF嗎?
為了將PPT/PPTX轉換為PDF,文本將使用Aspose.Slides for .NET,在本文中,將展示一系列功能,以使用C#將PowerPoint PPT無縫轉換為PDF或將PPTX無縫轉換為PDF。很高興的是,Aspose.Slides已經迎來2020第一次更新,增強了多項功能,如果你還沒有升級Aspose.Slides最新版測試,可以點擊這里下載。
本文由以下PowerPoint到PDF轉換功能組成。
以下是使用Aspose.Slides for .NET將PowerPoint演示文稿轉換為PDF的簡單步驟。
下面的代碼示例演示如何在C#中將PowerPoint PPT轉換為PDF。
// Instantiate a Presentation object that represents a PPT file Presentation presentation = new Presentation("PowerPoint.ppt"); // Save the presentation as PDF presentation.Save("PPT-to-PDF.pdf", SaveFormat.Pdf);
通過定義不同的選項(例如Jpeg質量,文本壓縮級別,圖元文件的行為等)來自定義PowerPoint至PDF的轉換。您可以使用PdfOptions類設置這些選項。
下面的代碼示例演示如何使用C#中的自定義選項將PowerPoint轉換為PDF。
// Instantiate a Presentation object that represents a PPTX file Presentation presentation = new Presentation("PowerPoint.pptx"); // Instantiate the PdfOptions class PdfOptions pdfOptions = new PdfOptions(); // Set Jpeg quality pdfOptions.JpegQuality = 90; // Set behavior for metafiles pdfOptions.SaveMetafilesAsPng = true; // Set text compression level pdfOptions.TextCompression = PdfTextCompression.Flate; // Define the PDF standard pdfOptions.Compliance = PdfCompliance.Pdf15; // Save the presentation as PDF presentation.Save("PowerPoint-to-PDF.pdf", SaveFormat.Pdf, pdfOptions);
PowerPoint演示文稿可能還包含隱藏的幻燈片。默認情況下,隱藏的幻燈片不包含在PPT / PPTX到PDF的轉換中。如果要轉換包含隱藏幻燈片的演示文稿,可以使用PdfOptions.ShowHiddenSlides屬性指定它。
下面的代碼示例演示如何將PowerPoint PPTX轉換為PDF,包括C#中的隱藏幻燈片。
// Instantiate a Presentation object that represents a PPTX file Presentation presentation = new Presentation("PowerPoint.pptx"); // Instantiate the PdfOptions class PdfOptions pdfOptions = new PdfOptions(); // Include hidden slides pdfOptions.ShowHiddenSlides = true; // Save the presentation as PDF presentation.Save("PowerPoint-to-PDF.pdf", SaveFormat.Pdf, pdfOptions);
除了轉換整個演示文稿之外,還可以將演示文稿的選定幻燈片轉換為PDF。為此,可以定義包含幻燈片編號的整數數組,然后將該數組傳遞給 Save(String,Int32 [],SaveFormat.Pdf)方法。
下面的代碼示例演示如何在C#中將PowerPoint PPT / PPTX的選定幻燈片轉換為PDF。
// Instantiate a Presentation object that represents a PPTX file Presentation presentation = new Presentation("PowerPoint.pptx"); // Setting array of slides positions int[] slides = { 1, 3 }; // Save the presentation as PDF presentation.Save("PPTX-to-PDF.pdf", slides, SaveFormat.Pdf);
PDF格式支持設置密碼和訪問權限以保護文檔。如果要在將PowerPoint轉換為PDF時應用這種保護機制,可以使用PdfOptions類來實現。
下面的代碼示例演示如何在C#中將PowerPoint PPTX轉換為PDF時設置密碼和指定訪問權限。
// Instantiate a Presentation object that represents a PPTX file Presentation presentation = new Presentation("PowerPoint.pptx"); /// Instantiate the PdfOptions class PdfOptions pdfOptions = new PdfOptions(); // Setting PDF password and access permissions pdfOptions.Password = "password"; pdfOptions.AccessPermissions = PdfAccessPermissions.PrintDocument | PdfAccessPermissions.HighQualityPrint; // Save the presentation as PDF presentation.Save("PPTX-to-PDF.pdf", SaveFormat.Pdf, pdfOptions);
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn