Asp.net converts ppt documents to pdf and asp. netppt documents pdf

Source: Internet
Author: User

Asp.net converts ppt documents to pdf and asp. netppt documents pdf

1. Add reference

 

Using Microsoft. Office. Core;
Using Microsoft. Office. Interop. PowerPoint;

 

Ii. Conversion Method

C # code Replication
/// <Summary> /// convert a PowerPoint file to a PDF file // </summary> /// <param name = "sourcePath"> source file path </param >/// <param name = "targetPath"> target file path </param> /// <returns> returns true if the file is successfully created, false is returned for failure </returns> public static bool PPTConvertToPDF (string sourcePath, string targetPath) {bool result; PpSaveAsFileType ppSaveAsFileType = PpSaveAsFileType. ppSaveAsPDF; // convert to pdf object missing = Type. missing; Microsoft. office. interop. po WerPoint. applicationClass application = null; Presentation persentation = null; try {application = new Microsoft. office. interop. powerPoint. applicationClass (); persentation = application. presentations. open (sourcePath, MsoTriState. msoTrue, MsoTriState. msoFalse, MsoTriState. msoFalse); if (persentation! = Null) {persentation. SaveAs (targetPath, ppSaveAsFileType, MsoTriState. msoTrue) ;}result = true ;}catch {result = false;} finally {if (persentation! = Null) {persentation. Close (); persentation = null;} if (application! = Null) {application. Quit (); application = null ;}} return result ;}

 

Iii. Call

 

OfficeToPdf. PPTToPDF ("d :\\ 12345. Pptx "," d :\\ 12345. Pdf ");

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.