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 Basic.NET>PDF Documents to JPEG

Converting PDF Documents to JPEG for Visual Basic.NET


'----------------------------------------------------------------------
' 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) Open your project in Microsoft Visual Basic.NET.
'
' 4) In Visual Basic main menu press "Project->Add Reference...".
'
' 5) In "Add Reference" window go to "COM" tab and double click into 
'    "Universal Document Converter Type Library".
'----------------------------------------------------------------------

Private Sub PrintAdobePDFToJPEG(ByVal strFilePath As String)
    Dim objAdobeApp As Object
    Dim itfAVDocument As Object
    Dim itfPDDocument As Object
    Dim nPages As Long
    Dim objUDC As UDC.IUDC
    Dim itfPrinter As UDC.IUDCPrinter
    Dim itfProfile As UDC.IProfile
    
    Dim AppDataPath As String
    Dim ProfilePath As String       
    ' Use Universal Document Converter API to change settings of converterd document
    objUDC = New UDC.APIWrapper
    itfPrinter = objUDC.Printers("Universal Document Converter")
    itfProfile = itfPrinter.Profile
    ' Adobe Acrobat API allow to print only on the default printer
    objUDC.DefaultPrinter = "Universal Document Converter"
    ' 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.          
    AppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
    ProfilePath = Path.Combine(AppDataPath, "UDC Profiles\PDF to JPEG.xml")            
    itfProfile.Load(ProfilePath)
    itfProfile.OutputLocation.Mode = UDC.LocationModeID.LM_PREDEFINED
    itfProfile.OutputLocation.FolderPath = "C:\Out"
    itfProfile.PostProcessing.Mode = UDC.PostProcessingModeID.PP_OPEN_FOLDER
    ' Run Adobe Acrobat as COM-server
    On Error Resume Next
    objAdobeApp = CreateObject("AcroExch.App")
    itfAVDocument = CreateObject("AcroExch.AVDoc")
    ' Open PDF document from file
    If itfAVDocument.Open(strFilePath, "") = True Then
        itfPDDocument = itfAVDocument.GetPDDoc()
        nPages = itfPDDocument.GetNumPages()
        ' Print all pages of the document
        Call itfAVDocument.PrintPagesSilent(0, nPages - 1, 0, True, True)
        ' Close the document
        Call itfAVDocument.Close(True)
        itfAVDocument = Nothing
        itfPDDocument = Nothing
    End If
    ' Close Adobe Acrobat Writer
    Call objAdobeApp.Exit()
    objAdobeApp = Nothing
End Sub


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