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>Delphi>PDF Documents to JPEG

Converting PDF Documents to JPEG for Delphi


//////////////////////////////////////////////////////////////////////////////////////////////////// // This example was designed for using in Delphi 7 or higher. // // 1. Adobe Acrobat Writer 4.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 "Universal Document Converter Type Library" and "Adobe Acrobat XX.0 Type Library" type libraries to the project. // XX is the Adobe Acrobat version installed on your computer. // // Delphi 7: // Use the Project | Import Type Library menu. // Delphi 2006 or latter: // Use the Component | Import Component menu. // // Clear the "Generate Component Wrapper" checkbox and click the "Create Unit" button (Delphi 7) or // select the "Create Unit" option (Delphi 2006 or latter). // //////////////////////////////////////////////////////////////////////////////////////////////////// program PDFToJPEG; {$APPTYPE CONSOLE} uses SysUtils, Variants, Windows, Dialogs, ActiveX, ComObj, UDC_TLB, Acrobat_TLB; procedure PrintPDFtoJPEG(PDFFilePath: string); var objUDC: IUDC; Printer: IUDCPrinter; Profile: IProfile; AcroApp: Variant; AVDoc: Variant; PDDoc: Variant; nPages: Integer; nPSLevel, bBinaryOk, bShrinkToFit, bNoSave: Integer; begin //Create a UDC object and get its interfaces objUDC := CoAPIWrapper.Create; Printer := objUDC.get_Printers('Universal Document Converter'); 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 Windows API's SHGetSpecialFolderPath //or JCL's JclSysInfo.GetAppdataFolder function. //Or you can move default profiles into a folder you prefer. Profile.Load('PDF to JPEG.xml'); Profile.OutputLocation.Mode := LM_PREDEFINED; Profile.OutputLocation.FolderPath := 'c:\UDC Output Files'; Profile.PostProcessing.Mode := PP_OPEN_FOLDER; AcroApp := CreateOleObject('AcroExch.App'); AVDoc := AcroApp.GetActiveDoc; //Open PDF document from file AVDoc.Open(PDFFilePath, ''); PDDoc := AVDoc.GetPDDoc; nPages := PDDoc.GetNumPages; //Print all pages of the document nPSLevel := 0; bBinaryOk := 1; //true bShrinkToFit := 1; //true AVDoc.PrintPagesSilent(0, nPages - 1, nPSLevel, bBinaryOk, bShrinkToFit); //Close the document bNoSave := 1; AVDoc.Close(bNoSave); //Close Acrobat AcroApp.Exit; end; var TestFilePath: string; begin TestFilePath := ExtractFilePath(ParamStr(0)) + 'TestFile.pdf'; try CoInitialize(nil); try PrintPDFtoJPEG(TestFilePath); finally CoUninitialize; end; except on E: Exception do MessageDlg(E.ClassName + ' : ' + E.Message, mtError, [mbOK], 0); end; end.


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