////////////////////////////////////////////////////////////////////////////////////////////////////// This example was designed for using in Microsoft Visual C# from // Microsoft Visual Studio 2003 or above.//// 1. Adobe Acrobat 6.0 or above should be installed and activated on your PC.// Adobe Acrobat Reader does not have COM interface and cannot be used as COM-server!//// 2. Universal Document Converter 5.2 or above should be installed, too.//// 3. Add references to "Adobe Acrobat X.0 Type Library" and "Universal Document Converter Type Library"// using the Project | Add Reference menu > COM tab.// The version number in the type library name may be different depending on Acrobat's version // installed on your computer.////////////////////////////////////////////////////////////////////////////////////////////////////using System;
using System.IO;
using UDC;
using Acrobat;
namespace PDFtoJPEG
{
classProgram
{
staticvoid PrintPDFtoJPEG(string PDFFilePath)
{
//Create a UDC object and get its interfacesIUDC objUDC = newAPIWrapper();
IUDCPrinter Printer = objUDC.get_Printers("Universal Document Converter");
IProfile Profile = Printer.Profile;
//Adobe Acrobat API allow to print only on the default printer
objUDC.DefaultPrinter = "Universal Document Converter";
//Use Universal Document Converter API to change settings of converterd document//Load profile located in folder "%APPDATA%\UDC Profiles".//Value of %APPDATA% variable should be received using Environment.GetFolderPath method.//Or you can move default profiles into a folder you prefer.string AppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string ProfilePath = Path.Combine(AppDataPath, @"UDC Profiles\PDF to JPEG.xml");
Profile.Load(ProfilePath);
Profile.OutputLocation.Mode = LocationModeID.LM_PREDEFINED;
Profile.OutputLocation.FolderPath = @"c:\UDC Output Files";
Profile.PostProcessing.Mode = PostProcessingModeID.PP_OPEN_FOLDER;
AcroApp AcroApp = newAcroAppClass();
AcroAVDoc AVDoc = newAcroAVDocClass();
//Open PDF document from file
AVDoc.Open(PDFFilePath, "");
AcroPDDoc PDDoc = (AcroPDDoc)AVDoc.GetPDDoc();
int nPages = PDDoc.GetNumPages();
//Print all pages of the documentint nPSLevel = 0;
int bBinaryOk = 1; //trueint bShrinkToFit = 1; //true
AVDoc.PrintPagesSilent(0, nPages - 1, nPSLevel, bBinaryOk, bShrinkToFit);
//Close the documentint bNoSave = 1;
AVDoc.Close(bNoSave);
//Close Acrobat
AcroApp.Exit();
}
staticvoid Main(string[] args)
{
string TestFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestFile.pdf");
PrintPDFtoJPEG(TestFilePath);
}
}
}