Universal Document Converter
Product Overview
Download
Purchase
Tutorials
Developer Solutions
Support Service
About fCoder SIA


      Site search
   


      Popular conversions
PDF to JPG converter
Convert Word to PDF
Convert PDF to TIFF
Autocad to PDF converter
Convert Word to JPG
Powerpoint to PDF converter
Printing to PDF
Convert Excel to PDF
Convert DJVU to PDF
Convert Web Page to PDF

      Video tutorials
Show tutorial



Main page>Developer Solutions>Examples>Visual C#>PDF Documents to JPEG

Converting PDF Documents to JPEG for Visual C#


//////////////////////////////////////////////////////////////////////////////////////////////////// // 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 { class Program { static void PrintPDFtoJPEG(string PDFFilePath) { //Create a UDC object and get its interfaces IUDC objUDC = new APIWrapper(); 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 = new AcroAppClass(); AcroAVDoc AVDoc = new AcroAVDocClass(); //Open PDF document from file AVDoc.Open(PDFFilePath, ""); AcroPDDoc PDDoc = (AcroPDDoc)AVDoc.GetPDDoc(); int nPages = PDDoc.GetNumPages(); //Print all pages of the document int nPSLevel = 0; int bBinaryOk = 1; //true int bShrinkToFit = 1; //true AVDoc.PrintPagesSilent(0, nPages - 1, nPSLevel, bBinaryOk, bShrinkToFit); //Close the document int bNoSave = 1; AVDoc.Close(bNoSave); //Close Acrobat AcroApp.Exit(); } static void Main(string[] args) { string TestFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestFile.pdf"); PrintPDFtoJPEG(TestFilePath); } } }


© fCoder SIA About fCoder SIA | Privacy Policy | Site Map