ASP.net implementation method for translating PPT documents into PDF-Practical tips

Source: Internet
Author: User

This article illustrates the asp.net implementation of the method of translating a PPT document into PDF. Share to everyone for your reference. The implementation methods are as follows:

One, add a reference

Copy Code code as follows:
Using Microsoft.Office.Core;
Using Microsoft.Office.Interop.PowerPoint;

Second, the conversion method

Copy Code code as follows:
<summary>
Convert PowerPoint files to PDF format files
</summary>
<param name= "SourcePath" > source file path </param>
<param name= "TargetPath" > Destination file path </param>
<returns> returns true successfully, Failure returns false</returns>
public static bool Pptconverttopdf (string SourcePath, String TargetPath)
{
BOOL result;
PpSaveAsFileType PpSaveAsFileType = ppsaveasfiletype.ppsaveaspdf;//converted 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;
}

Third, call

Copy Code code as follows:
Officetopdf.ppttopdf ("D:\\12345.pptx", "d:\\12345.pdf");

I hope this article will help you with the ASP.net program design.

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.