Asp.net converts a ppt document to a pdf file. pptpdf

Source: Internet
Author: User

Asp.net converts a ppt document to a pdf file. pptpdf

This document describes how to convert a ppt document to a pdf file by using asp.net. Share it with you for your reference. The specific implementation method is as follows:

1. Add reference
Copy codeThe Code is as follows: using Microsoft. Office. Core;
Using Microsoft. Office. Interop. PowerPoint;

Ii. Conversion Method

Copy codeThe Code is as follows: // <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> success returns true, failure returns false </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. PowerPoint. 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
Copy codeThe Code is as follows: OfficeToPdf. PPTToPDF ("d :\\ 12345.pptx", "d :\\ 12345.pdf ");

I hope this article will help you design your asp.net program.

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.