Last post Dec 14, 2012 02:20 AM by Minsa
None
0 Points
1 Post
Dec 14, 2012 02:20 AM|Minsa|LINK
Hi;
Code for converting ppt/pps to pdf
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"; }
<div> <object type="application/pdf" data="<%= FileName %>" width="1024" height="768"> </div>
None
0 Points
1 Post
Code for converting ppt/pps to pdf
Dec 14, 2012 02:20 AM|Minsa|LINK
Hi;
Code for converting ppt/pps to pdf
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";
}
<div>
<object type="application/pdf" data="<%= FileName %>" width="1024" height="768">
</div>