请查收!使用Aspose.Slides在.NET中将PowerPoint PPT或PPTX转换为PDF完整指南

为了将PPT/PPTX转换为PDF,文本将使用Aspose.Slides for .NET,在本文中,将展示一系列功能,以使用C#将PowerPoint PPT无缝转换为PDF或将PPTX无缝转换为PDF。

您是否正在寻找将PowerPoint PPT / PPTX转换为PDF的可靠而简单的解决方案想将PowerPoint演示文稿准确地高质量转换为PDF吗/span>

为了将PPT/PPTX转换为PDF,文本将使用Aspose.Slides for .NET,在本文中,将展示一系列功能,以使用C#将PowerPoint PPT无缝转换为PDF或将PPTX无缝转换为PDF。很高兴的是,Aspose.Slides已经迎来2020第一次更新,增强了多项功能,如果你还没有升级Aspose.Slides最新版测试,可以点击这里下载

使用Aspose.Slides在.NET中将PowerPoint PPT或PPTX转换为PDF完整指南

本文由以下PowerPoint到PDF转换功能组成。

  • 在C#中将PowerPoint(PPT或PPTX)转换为PDF
  • 自定义将PPT或PPTX转换为PDF
  • 将PPT或PPTX中的隐藏幻灯片转换为PDF
  • 将PowerPoint演示文稿的特定幻灯片转换为PDF
  • 将PowerPoint演示文稿转换为具有所需访问权限的受密码保护的PDF

在C#中将PowerPoint PPT或PPTX转换为PDF

以下是使用Aspose.Slides for .NET将PowerPoint演示文稿转换为PDF的简单步骤。

  • 创建Presentation类的对象,并使用PowerPoint演示文稿文件的路径对其进行初始化。
  • 使用Presentation.Save(string outputFilePath,SaveFormat.Pdf)方法将文件另存为PDF。

下面的代码示例演示如何在C#中将PowerPoint PPT转换为PDF。

// Instantiate a Presentation object that represents a PPT filePresentation presentation = new Presentation("PowerPoint.ppt");// Save the presentation as PDFpresentation.Save("PPT-to-PDF.pdf", SaveFormat.Pdf);

使用C#中的自定义选项将PPT或PPTX转换为PDF

通过定义不同的选项(例如Jpeg质量,文本压缩级别,图元文件的行为等)来自定义PowerPoint至PDF的转换。您可以使用PdfOptions类设置这些选项。

下面的代码示例演示如何使用C#中的自定义选项将PowerPoint转换为PDF。

// Instantiate a Presentation object that represents a PPTX filePresentation presentation = new Presentation("PowerPoint.pptx");// Instantiate the PdfOptions classPdfOptions pdfOptions = new PdfOptions();// Set Jpeg qualitypdfOptions.JpegQuality = 90;// Set behavior for metafilespdfOptions.SaveMetafilesAsPng = true;// Set text compression levelpdfOptions.TextCompression = PdfTextCompression.Flate;// Define the PDF standardpdfOptions.Compliance = PdfCompliance.Pdf15;// Save the presentation as PDFpresentation.Save("PowerPoint-to-PDF.pdf", SaveFormat.Pdf, pdfOptions);

将PowerPoint演示文稿的隐藏幻灯片转换为C#中的PDF

PowerPoint演示文稿可能还包含隐藏的幻灯片。默认情况下,隐藏的幻灯片不包含在PPT / PPTX到PDF的转换中。如果要转换包含隐藏幻灯片的演示文稿,可以使用PdfOptions.ShowHiddenSlides属性指定它。

下面的代码示例演示如何将PowerPoint PPTX转换为PDF,包括C#中的隐藏幻灯片。

// Instantiate a Presentation object that represents a PPTX filePresentation presentation = new Presentation("PowerPoint.pptx");// Instantiate the PdfOptions classPdfOptions pdfOptions = new PdfOptions();// Include hidden slidespdfOptions.ShowHiddenSlides = true;// Save the presentation as PDFpresentation.Save("PowerPoint-to-PDF.pdf", SaveFormat.Pdf, pdfOptions);

在C#中将PowerPoint PPT / PPTX的选定幻灯片转换为PDF

除了转换整个演示文稿之外,还可以将演示文稿的选定幻灯片转换为PDF。为此,可以定义包含幻灯片编号的整数数组,然后将该数组传递给 Save(String,Int32 [],SaveFormat.Pdf)方法。

下面的代码示例演示如何在C#中将PowerPoint PPT / PPTX的选定幻灯片转换为PDF。

// Instantiate a Presentation object that represents a PPTX filePresentation presentation = new Presentation("PowerPoint.pptx");// Setting array of slides positionsint[] slides = { 1, 3 };// Save the presentation as PDFpresentation.Save("PPTX-to-PDF.pdf", slides, SaveFormat.Pdf);

将PowerPoint PPT / PPTX转换为具有访问权限的受密码保护的PDF

PDF格式支持设置密码和访问权限以保护文档。如果要在将PowerPoint转换为PDF时应用这种保护机制,可以使用PdfOptions类来实现。

下面的代码示例演示如何在C#中将PowerPoint PPTX转换为PDF时设置密码和指定访问权限。

// Instantiate a Presentation object that represents a PPTX filePresentation presentation = new Presentation("PowerPoint.pptx");/// Instantiate the PdfOptions classPdfOptions pdfOptions = new PdfOptions();// Setting PDF password and access permissionspdfOptions.Password = "password";pdfOptions.AccessPermissions = PdfAccessPermissions.PrintDocument | PdfAccessPermissions.HighQualityPrint;// Save the presentation as PDFpresentation.Save("PPTX-to-PDF.pdf", SaveFormat.Pdf, pdfOptions);


还想要更多吗可以点击阅读【2019 · Aspose最新资源整合】查找需要的教程资源。如果您有任何疑问或需求,请随时加入Aspose技术交流群(),我们很高兴为您提供查询和咨询
标签:

来源:慧都

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2020年1月10日
下一篇 2020年1月10日

相关推荐

发表回复

登录后才能评论