////////////////////////////////////////////////////////////////////////////////////////////////////// This example was designed for using in Microsoft Visual C# from // Microsoft Visual Studio 2003 or above.//// 1. Microsoft PowerPoint 97 or above should be installed and activated on your PC.//// 2. Universal Document Converter 5.2 or above should be installed, too.//// 3. Add references to "Microsoft PowerPoint XX.0 Object Library" and "Universal Document Converter Type Library"// using the Project | Add Reference menu > COM tab.// XX is the Microsoft Office version installed on your computer.////////////////////////////////////////////////////////////////////////////////////////////////////using System;
using System.IO;
using UDC;
using PowerPoint = Microsoft.Office.Interop.PowerPoint; //using PowerPoint; in VS2003using MSO = Microsoft.Office.Core;
namespace PowerPointToJPEG
{
classProgram
{
staticvoid PowerPointToJPEG(string PowerPointFilePath)
{
//Create a UDC object and get its interfacesIUDC objUDC = newAPIWrapper();
IUDCPrinter Printer = objUDC.get_Printers("Universal Document Converter");
IProfile Profile = Printer.Profile;
//Use Universal Document Converter API to change settings of converterd document
Profile.PageSetup.Orientation = PageOrientationID.PO_LANDSCAPE;
Profile.FileFormat.ActualFormat = FormatID.FMT_JPEG;
Profile.FileFormat.JPEG.ColorSpace = ColorSpaceID.CS_TRUECOLOR;
Profile.OutputLocation.Mode = LocationModeID.LM_PREDEFINED;
Profile.OutputLocation.FolderPath = @"c:\UDC Output Files";
Profile.OutputLocation.FileName = @"&[DocName(0)] -- &[Date(0)] -- &[Time(0)].&[ImageType]";
Profile.OutputLocation.OverwriteExistingFile = false;
Profile.PostProcessing.Mode = PostProcessingModeID.PP_OPEN_FOLDER;
//Run Microsoft Excel as COM-server
PowerPoint.Application PowerPointApp = new PowerPoint.ApplicationClass();
//Open document from file
PowerPoint.Presentation Presentation = PowerPointApp.Presentations.Open(PowerPointFilePath, MSO.MsoTriState.msoTrue, MSO.MsoTriState.msoTrue, MSO.MsoTriState.msoFalse);
//Print all slides from the presentation
PowerPoint.PrintOptions PrintOptions = Presentation.PrintOptions;
PrintOptions.PrintInBackground = MSO.MsoTriState.msoFalse;
PrintOptions.ActivePrinter = "Universal Document Converter";
Presentation.PrintOut(0, Presentation.Slides.Count, "", 1, MSO.MsoTriState.msoFalse);
//Close the presentation
Presentation.Close();
//Close Microsoft PowerPoint
PowerPointApp.Quit();
}
staticvoid Main(string[] args)
{
string TestFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestFile.ppt");
PowerPointToJPEG(TestFilePath);
}
}
}