public static int ConvertPowerPointToPDF()
{
string InputFilePath = @"C:\Users\\Desktop\tst1.pps";
string OutputFilePath = @"C:\Users\\Desktop\tst1.pdf";
int Errors = 0;
Microsoft.Office.Interop.PowerPoint._Application PPApplication = null;
Presentation PPDoc = null;
try
{
// Start an instance of PowerPoint
PPApplication = new Application();
//PPApplication.Visible = True
// Open the source document.
PPDoc = PPApplication.Presentations.Open(InputFilePath);
PPDoc.SaveAs(OutputFilePath, PpSaveAsFileType.ppSaveAsPDF);
//PPDoc.ExportAsFixedFormat(OutputFilePath, PpFixedFormatType.ppFixedFormatTypePDF, PpFixedFormatIntent.ppFixedFormatIntentScreen, Microsoft.Office.Core.MsoTriState.msoCTrue, PpPrintHandoutOrder.ppPrintHandoutHorizontalFirst, PpPrintOutputType.ppPrintOutputBuildSlides, Microsoft.Office.Core.MsoTriState.msoFalse, , , , False, False, False, False, False)
}
catch (Exception ex)
{
//Interaction.MsgBox(ex.Message);
//Errors = 1;
}
finally
{
// Close and release the Document object.
if ((PPDoc != null))
{
PPDoc.Close();
PPDoc = null;
}
// Quit PowerPoint and release the ApplicationClass object.
if ((PPApplication != null))
{
PPApplication.Quit();
PPApplication = null;
}
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
}
return Errors;
}
and to display the pdf file
protected void Page_Load(object sender, EventArgs e)
{
FileName ="tst1.pdf";
}
Comments
Post a Comment