PDF to IMAGE SDK
     
   Overview  
   Functions  
   System requestment  
   Getting started  
   SDK reference.
  • Interfaces
  • Constants
  • Properties
     
       How to ...
  • How to create multipages tiff images?
  • How to create memory stream images?
  • How to increase/decrease the file size of an image?
     
       Registration  
       Copyright&License  
     1. Overview
     

    Pdf to Image SDK is a powerful pdf sdk/api, it produces fully functional image documents with text, pictures, graphics etc, using the original pdf document formatting. It does not need any software support, such as Adobe Acrobat, Acrobat Reader, etc.
    Pdf to Image SDK supports multifarious image format, such as 'bmp', 'tiff', 'jpg', 'gif', 'png', 'emf', 'wmf', 'pcx' etc, supports multifarious compression mode of tiff image, supports to select individual pages for conversion, supports CCITT fax image files.
    Pdf to Image SDK supports some reasonable function interfaces. It can be easily used to VC/VB/.NET/C++Builder/Delphi and other development platforms. The client license is required for application development, using client license you can integrate the sdk into your application.

     

     2. Functions
    (01)  It quickly convert pdf document to image document.
    (02)  It supports CCITT fax image files.
    (03)  It supports encrypted pdf file.
    (04)  It supports to select individual pages for conversion.
    (05)  It supports conversion of vector graphics into image files.
    (06)  It supports multifarious image format, such as 'bmp', 'tiff', 'jpg', 'gif', 'png', 'emf', 'wmf', 'pcx' etc.
    (07)  It supports to generate multipage tiff files.
    (08)  It supports any resolution in the generated image files.
    (09)  It supports conversion into color 1bit, 4bits, 8bits,4bits grayscale, 8tits grayscale and 24bits per pixel format image.
    (10)  It supports multifarious compression of tiff image, such as LZW, JPEG, PACKBITS, CCITT Group3, CCITT Group4, RLE etc.
    (11)  It allows you to preserve original document layout.
    (12)  It supports windows 2000/xp/2003/vista and windows 7 platform.
    (13)  It does not require Adobe Acrobat or Reader support.
    (14)  It supports Adobe Acrobat 3.0, 4.0, 5.0, 6.0 compatibility.

     3. System requestment

         Supported Operation Systems  
         The following operation systems listed have been tested with PDF to IMAGE SDK and are officially supported.  
          (1) Microsoft Windows 2000 Professional;
          (2) Microsoft Windows 2000 Server and Advanced Server;
          (3) Microsoft Windows 2003 Server 32-bit Web Edition, Standard Edition and Enterprise Edition;
          (4) Microsoft Windows XP Professional and Home Edition;
          (5) Microsoft Windows Vista Ultimage and Home Edition;
          (6) Microsoft Windows 7.

         Recommended hardware  
          (1) CPU: Intel(or Standard PC) 800MHz or faster compatible x86 processor;
          (2) RAM: 256MB or more RAM recommended, 128MB minimum;
          (3) Hard-disk: 100MB free space recommended, 50MB free space required;

     4. Getting Started
      This section describes how to use PDF to IMAGE SDK quickly. Pdf to Image SDK is very easy to use.
      The first step is to copy 'pdf2image.dll' to the windows system directory or to your own executable application directory.
      The next is to create your own application using the dll and build it.

    The Pdf to IMAGE SDK is a zip archive, which contains various files including runtime binary executable codes, developer's samples and documents, and license file etc.
    You can unzip the archive using a tool like WinZip or WinRAR.
    The archive contians the following subdirectories.
    bin:  It contians the runtime binary executable codes.
    doc:  It contians the user's manuals and license file.
    include:   It contians header files which included in your vc,c++builder,delphi or other development platforms.
    samples:   It contians vc,vb,c++builder,delphi,c#,vb.net sample programes and so on.
      
     
         Using PDF to IMAGE SDK in VB
         step 1.   Defining the DLL's interfaces and loading the DLL.
      '1.1 SDK interface definitions.
    Private Declare Function apOpen Lib "pdf2image.dll" (ByVal lpFileName As String, ByVal lpOwnerPw As String, ByVal lpUserPw As String) As Long

    Private Declare Function apClose Lib "pdf2image.dll" (ByVal nHandle As Long) As Long

    Private Declare Function apConvert Lib "pdf2image.dll" (ByVal nHandle As Long) As Long

    Private Declare Function apConvertPage Lib "pdf2image.dll" (ByVal nHandle As Long, ByVal nPageNo As Long) As Long

    Private Declare Function apConvertPageToStream Lib "pdf2image.dll" (ByVal nHandle As Long, ByVal nPageNo As Long, ByRef pImageStream As Long, ByRef nSize As Long) As Long

    Private Declare Function apSetProperty Lib "pdf2image.dll" (ByVal nHandle As Long, ByVal nIndex As Long, ByVal lpValue As String, ByVal nValue As Long, ByVal nOther As Long) As Long

    Private Declare Function apGetProperty Lib "pdf2image.dll" (ByVal nHandle As Long, ByVal nIndex As Long, ByRef lpValue As String, ByRef nValue As Long) As Long

         step 2.   Defining the requested constants.
      '1.2 Definitions of converter's properties
    '===============================================================
    'read/write properties

    Const AP_PROP_OUTDIR = 1   'Destination directory.
    Const AP_PROP_PREFIX = 2   
    'The prefix of the name of result image file.
    Const AP_PROP_PAGEZOOM = 3   'Zoom scale of the source pdf page.
    Const AP_PROP_BGCOLOR = 4   'Image background color.
    Const AP_PROP_IMAGETYPE = 5   'Result image format.
    Const AP_PROP_BITCOUNT = 6   'Color bits per pixel.
    Const AP_PROP_XDPI = 7   
    'Horizontal resolution.
    Const AP_PROP_YDPI = 8   
    'Vertical resolution.
    Const AP_PROP_QUALITY = 9   
    'JPEG compression quality.
    Const AP_PROP_COMPRESSION = 10  
     'TIFF compression mode.
    Const AP_PROP_MULTIPAGES = 11   'Multipages TIFF file.
    Const AP_PROP_GRAYSCALE = 12   
    'Grayscale image.
    Const AP_PROP_XDIMENSIONS = 13   'The width of the result image in pixel
    Const AP_PROP_YDIMENSIONS = 14   'The height of the result image in pixel

    'read only properties
    Const AP_PROP_PAGECOUNT = 20   
    'The total pages of source pdf file.
    Const AP_PROP_PAGEHEIGHT = 21  'Height of the current page of source pdf file.
    Const AP_PROP_PAGEWIDTH = 22   
    'Width of the current page of source pdf file.
    '===============================================================

    '1.3 TIFF tag's definitions.
    '===============================================================
    Const AP_TIFF_COMPRESSION_NONE = 0
    Const AP_TIFF_COMPRESSION_LZW = 1
    Const AP_TIFF_COMPRESSION_JPEG = 2
    Const AP_TIFF_COMPRESSION_PACKBITS = 3 
    Const AP_TIFF_COMPRESSION_CCITTG4 = 4
    Const AP_TIFF_COMPRESSION_CCITTG3 = 5 
    Const AP_TIFF_COMPRESSION_RLE = 6

    '===============================================================

    '1.4 Image type's definitions
    '===============================================================
    Const AP_IMAGE_BMP = 1
    Const AP_IMAGE_EMF = 2
    Const AP_IMAGE_WMF = 3
    Const AP_IMAGE_JPG = 4
    Const AP_IMAGE_PNG = 5
    Const AP_IMAGE_GIF = 6
    Const AP_IMAGE_TIF = 7
    Const AP_IMAGE_PCX = 8

    Const AP_IMAGE_JPEG = 4
    Const AP_IMAGE_TIFF = 7

    '===============================================================

    '1.5 Return code's definitions.
    '===============================================================
    Const RTN_OK = 1 'Successful operation.
    Const ERR_UNKNOWN = -99 'Unknown system error.

    Const ERR_OVER_MAXTHREADS = -1 'Over the limit amount of threads
    Const ERR_FILE_UNEXIST = -2 'Source PDF file unexist.
    Const ERR_FILE_DAMAGED = -3 'Source PDF file is damaged.
    Const ERR_FILE_RESTRICTED = -4 'Source PDF file is restricted.

    Const ERR_INVALID_PAGE = -5 'The PDF page is invalid.
    Const ERR_CONVERT_FAILURE = -8 'Conversion failure.
    Const ERR_INVALID_STREAM = -9 'Invalid memory stream address.
    Const ERR_INVALID_HANDLE = -10 'Invalid converter's handle.
    '===============================================================

      
         step 3.  The following is the source code.
     

    Dim nHandle As Long

    'Open pdf file and creating a converter.
    nHandle = apOpen("sample.pdf", "", "")
    Select Case nHandle
        Case ERR_OVER_MAXTHREADS
            MsgBox "Over the limit amount of threads,please waiting!"
            Exit Sub
        Case ERR_FILE_UNEXIST
            MsgBox "Source pdf file unexist!"
            Exit Sub
        Case ERR_FILE_DAMAGED
            MsgBox "Source pdf file damaged!"
            Exit Sub
        Case ERR_FILE_RESTRICTED
            MsgBox "Source pdf file restricted!"
            Exit Sub
    End Select


    'Setting the converter's propertys.
    'For more, please refer to above definitions.
    apSetProperty nHandle, AP_PROP_OUTDIR, "./demo1", 0, 0 'output directory
    apSetProperty nHandle, AP_PROP_IMAGETYPE, "", AP_IMAGE_PNG, 0 'image type

    'Get the amount of the source pdf pages
    Dim iPageCount, iPageNo As Long
    apGetProperty nHandle, AP_PROP_PAGECOUNT, "", iPageCount


    'To convert the pdf file.
    For iPageNo = 1 To iPageCount
        apConvertPage nHandle, iPageNo
    Next


    'Close pdf file and destory the converter.
    apClose (nHandle)

         Notice: For more detial samples please here to download PDF to Image SDK samples.

     5. Interfaces
         This section describes client sdk interfaces detailedly.
     
         (1). function---apOpen()
      This function opens a pdf file, if the pdf file is restricted, you can ensure owner password or user password. After it opens success, it will create a converter and return the converter's handle.
      。Syntax
      long apOpen(char *pPdfFileName, char *pOwnerPw, char *pUserPw);
      。Parameters
      pPdfFileName:   Source pdf file name. It supports absolute path and relative path.
      pOwnerPw:  Pdf owner password.
      pUserPw:   Pdf user password.
      。Return value
      If the function succeeds, it returns a converter's handle. If the function fail, it returns a error code, such as the following, for more error codes, please click here.
      ERR_OVER_MAXTHREADS: Over the limit amount of threads.
      ERR_FILE_UNEXIST: Source pdf file unexist.
      ERR_FILE_DAMAGED: Source pdf file is damaged, or not a correct pdf file.
      ERR_FILE_RESTRICTED: Source pdf file is restricted, such as password is wrong etc.
     
         (2). function---apClose()
      This function close the pdf file and destroy the converter appointed by the handle.
      。Syntax
      long apClose(long nHandle);
      。Parameters
      nHandle:  The converter's handle, which created by function---apOpen.
      。Return value
      It returns RTN_OK, the function succeeds, otherwise the function fails. For more error codes, please click here.
     
         (3). function---apConvert()
      This function converts all pages of the pdf file.
      。Syntax
      long apConvert(long nHandle);
      。Parameters
      nHandle:  The converter's handle, which created by function---apOpen.
      。Return value
      It returns RTN_OK,the function succeeds, otherwise the function fails. For more error codes, please click here.
     
         (4). function---apConvertPage()
      This function converts a certain page of the pdf file, the page appointed by the second parameter---nPageNo.
      。Syntax
      long apConvertPage(long nHandle,long nPageNo);
      。Parameters
      nHandle:  The converter's handle, which created by function---apOpen.
      nPageNo:  A certain page of the pdf file, which will be converted.
      。Return value
      It returns RTN_OK, the function succeeds, otherwise the function fails. For more error codes, please click here.
     
         (5). function---apConvertPageToStream()
      This function converts a certain page of the pdf file to memory stream, the page appointed by the second parameter---nPageNo.
      。Syntax
      long apConvertPageToStream(long nHandle,
                                                   long nPageNo,
                                                   BYTE *&pMemStream,
                                                   long &nSize);
      。Parameters
      nHandle:  The converter's handle, which created by function---apOpen.
      nPageNo:  A certain page of the pdf file, which will be converted.
      pMemStream: A pointer of memory stream, which point to result image's memory stream.
      nSize: It is the size of memory image stream.
      。Return value
      It returns RTN_OK, the function succeeds, otherwise the function fails. For more error codes, please click here.
      Notice:  The result image's memory stream managed by the sdk automatically. You need not to allocate or destory it manually.
     
         (6). function---apSetProperty()
      This function is to set the converter's properties, which created by function---apOpen.
      。Syntax
      long _apSetProperty( long nHandle,
                                   long nIndex,
                                   char *pValue,
                                   long nValue,
                                   long nOther);
      。Parameters
      nHandle:  The converter's handle, which created by function---apOpen.
      nIndex:  Property tag, refer to the section of definitions of converter's properties.
      pValue: A String value of the property. This parameter is valid only just the type of the current property is string.
      nValue: An integer value of the property. This parameter is valid only just the type of the current property is integer.
      nOther: Only valid for progress call-back. It is used to call-back function as a parameter value.
      。Return value
      It returns RTN_OK, the function succeeds, otherwise the function fails. For more error codes, please click here.
     
         (7). function---apGetProperty()
      This function is to get the converter's properties, which created by function---apOpen.
      。Syntax
      long _apGetProperty( long nHandle,
                                   long nIndex,
                                   char *pValue,
                                   long &nValue);
      。Parameters
      nHandle:  The converter's handle, which created by function---apOpen.
      nIndex:  Property tag, refer to the section of definitions of converter's properties.
      pValue: A String value of the property. This parameter is valid only just the type of the current property is string.
      nValue: An integer value of the property. This parameter is valid only just the type of the current property is integer.
      。Return value
      It returns RTN_OK, the function succeeds, otherwise the function fails. For more error codes, please click here.
     

     6. Constants
         
         (1). Definitions of converter's properties
      。 read/write properties
    Name Value Type Description
    AP_PROP_OUTDIR 1 string Destination directory.
    AP_PROP_PREFIX 2 string The prefix of the name of result image file.
    AP_PROP_PAGEZOOM 3 integer Zoom scale of the source pdf page(10-200%).
    AP_PROP_BGCOLOR 4 integer Image background color.
    AP_PROP_IMAGETYPE 5 integer Result image format.
    AP_PROP_BITCOUNT 6 integer Color bits per pixel(1bit,4bits,8bits,24bits).
    AP_PROP_XDPI 7 integer Horizontal resolution.
    AP_PROP_YDPI 8 integer Vertical resolution.
    AP_PROP_QUALITY 9 integer JPEG compression quality(0-100).
    AP_PROP_COMPRESSION 10 integer TIFF compression mode.
    AP_PROP_MULTIPAGES 11 integer Multipages TIFF file.
    AP_PROP_GRAYSCALE 12 integer Grayscale image.
    AP_PROP_XDIMENSIONS 13 integer The width of the result image in pixel.
    AP_PROP_YDIMENSIONS 14 integer The height of the result image in pixel.

    。 read only properties
    Name Value Type Description
    AP_PROP_PAGECOUNT 20 integer The total pages of source pdf file.
    AP_PROP_PAGEHEIGHT 21 integer Height of the current page of source pdf file.
    AP_PROP_PAGEWIDTH 22 integer Width of the current page of source pdf file.

    。 write only properties
    Name Value Type Description
    AP_PROP_PROGRESSFUNC 40 integer Address of the progress call-back function.

    Notice: For more detial properties, please click here.

         (2). TIFF compression tag's definitions(supported color depths in brackets)
     
     
    Name Value Description
    AP_TIFF_COMPRESSION_NONE 0 No compression(1-bit, 4-bits, 8-bits, 24-bits)
    AP_TIFF_COMPRESSION_LZW 1 Lzw compression(1-bit, 4-bits, 8-bits, 24-bits)
    AP_TIFF_COMPRESSION_JPEG 2 Jpeg compression(8-bits grayscale, 24-bits)
    AP_TIFF_COMPRESSION_PACKBITS 3 Packbits compression(4-bits, 8-bits, 24-bits)
    AP_TIFF_COMPRESSION_CCITTG4 4 CCITT Group 4 compression(1-bit)
    AP_TIFF_COMPRESSION_CCITTG3 5 CCITT Group 3 compression(1-bit)
    AP_TIFF_COMPRESSION_RLE 6 RLE compression(1-bit)

         (3). Image type's definitions
     
     
    Name Value Description
    AP_IMAGE_BMP 1 Bmp image.
    AP_IMAGE_EMF 2 Emf image.
    AP_IMAGE_WMF 3 Wmf image.
    AP_IMAGE_JPG 4 Jpg/Jpeg image.
    AP_IMAGE_PNG 5 Png image.
    AP_IMAGE_GIF 6 Gif image.
    AP_IMAGE_TIF 7 Tif/Tiff image.
    AP_IMAGE_PCX 8 Pcx image.
         
    AP_IMAGE_JPEG 4 Jpg/Jpeg image.
    AP_IMAGE_TIFF 7 Tif/Tiff image.

         (4). Return code's definitions
     
     
    Name Value Description
    RTN_OK 1 Successful operation.
    ERR_OVER_MAXTHREADS -1 Over the limit amount of threads.
    ERR_FILE_UNEXIST -2 Source PDF file unexist.
    ERR_FILE_DAMAGED -3 Source PDF file is damaged.
    ERR_FILE_RESTRICTED -4 Source PDF file is restricted.
    ERR_INVALID_PAGE -5 Invalid page of the source pdf.
    ERR_CONVERT_FAILURE -8 Conversion failure.
    ERR_INVALID_STREAM -9 Invalid memory stream's address.
    ERR_INVALID_HANDLE -10 Invalid converter's handle.
    ERR_UNKNOWN -99 Unknown system error.
     

     7. Properties
         This section describes the properties of the converter detailedly.
     
         (1). Property AP_PROP_OUTDIR
      This property can be using to set output directory which the result image files placed in. Default the output directory as same path as the source PDF document.
     
         (2). Property AP_PROP_PREFIX
      This property can be using to set the prefix of file name of the result image.

    For example, the file name of source pdf is 'test.pdf', you set the image type as 'JPEG' format and the value of this property as 'mytest', so the file name of result image are 'mytest00001.jpg', 'mytest00002.jpg',...,'mytest00XXX.jpg', etc.
     
         (3). Property AP_PROP_PAGEZOOM
      Th property can be using to set zoom scale of PDF pages(10-200).

    For example, if it sets the page zoom as 120 or 80 and the result image is a 800x600 pixel, so the final result image is a 960x720 pixel or 640x480 pixel image.
    Default page zoom is 100.
     
         (4). Property AP_PROP_IMAGETYPE
      This property can be using to set the result image type.
    The supported image formats are listed below:
     
    Constant Name Value Description
    AP_IMAGE_BMP 1 BMP fromat image.
    AP_IMAGE_EMF 2 EMF fromat image.
    AP_IMAGE_WMF 3 WMF fromat image.
    AP_IMAGE_JPG 4 JPG/JPEG fromat image.
    AP_IMAGE_PNG 5 PNG fromat image.
    AP_IMAGE_GIF 6 GIF fromat image.
    AP_IMAGE_TIF 7 TIF/TIFF fromat image.
    AP_IMAGE_PCX 8 PCX fromat image.
         
    AP_IMAGE_JPEG 4 JPG/JPEG fromat image.
    AP_IMAGE_TIFF 7 TIF/TIFF fromat image.
    Default is JPG/JPEG format image.
     
         (5). Property AP_PROP_BITCOUNT
      This property gets or sets the color depth of an image.
    The component supports the following color depths,default is 24.
      1:    black/white image.
      4:    16 colors image.
      8:    256 colors image.
      24:   true color image.
     
         (6). Property AP_PROP_XDPI
      This property gets or sets the horizontal resolution of the image.
    The component supports the resolution from 72 to 500, defualt is 120.
     
         (7). Property AP_PROP_YDPI
      This property gets or sets the vertical resolution of the image.
    The component supports the resolution from 72 to 500, defualt is 120.
     
         (8). Property AP_PROP_XDIMENSIONS
      This property can be used to specify the width of the final result image in pixel.
     
         (9). Property AP_PROP_YDIMENSIONS
      This property can be used to specify the height of the final result image in pixel.
     
         (10). Property AP_PROP_COMPRESSION
      Only the current output images are tiff format, this property is valid, the property can be used to get or set the compression type.
    The supported value of iCompression are listed below(supported color depths in brackets):
     
    Constant Name Value Description
    AP_TIFF_COMPRESSION_NONE 0 No compression(1-bit, 4-bits, 8-bits, 24-bits)
    AP_TIFF_COMPRESSION_LZW 1 Lzw compression(1-bit, 4-bits, 8-bits, 24-bits)
    AP_TIFF_COMPRESSION_JPEG 2 Jpeg compression(8-bits grayscale, 24-bits)
    AP_TIFF_COMPRESSION_PACKBITS 3 Packbits compression(4-bits, 8-bits, 24-bits)
    AP_TIFF_COMPRESSION_CCITTG4 4 CCITT Group 4 compression(1-bit)
    AP_TIFF_COMPRESSION_CCITTG3 5 CCITT Group 3 compression(1-bit)
    AP_TIFF_COMPRESSION_RLE 6 RLE compression(1-bit)
    Default is no compression.
     
         (11). Property AP_PROP_QUALITY
      This property gets or sets the compression quality(1..100) for lossy compression types. Default is 75.
     
         (12). Property AP_PROP_GRAYSCALE
      This property can be using to set grayscale image.
      TRUE(1):  It is to set grayscale image.
      FALSE(0):  It is to set non-grayscale image.
     
         (13). Property AP_PROP_MULTIPAGES
      This property can be using to set multipages tiff files.
      TRUE(1):  It is to set multipages tiff files.
      FALSE(0):  It is to set general tiff files.
     
         (14). Property AP_PROP_PAGECOUNT
      This property can be using to get the number of pages in the PDF document.
     
         (15). Property AP_PROP_PAGEWIDTH
      This property can be using to get the width of a pdf page. Afert the functon apConvertPage() or apConvertPageToStream() is invoked successful, this property will become valid.
     
         (16). Property AP_PROP_PAGEHEIGHT
      This property can be using to get the height of a pdf page. Afert the functon apConvertPage() or apConvertPageToStream() is invoked successful, this property will become valid.
     
         (17). Property AP_PROP_PROGRESSFUNC
      Address of the progress call-back function.
     

     8. How to ...
         
         (1) How to create multipages tiff images?
         The TIFF image format is a especial image format, which supports multipages images. Using Pdf to Image SDK to create multipages tiff images is very easy. All you need to is setting the multipages property of the converter which created by function---apOpen to TRUE(or 1).
         The VB code looks like the following.
            apSetProperty nHandle, AP_PROP_MULTIPAGES, "", 1, 0
         The VC code looks like the following.
            apSetProperty(nHandle, AP_PROP_MULTIPAGES, NULL, TRUE, 0);

         A completed code for creating multipages tiff in VB.
     
     

    Dim nHandle As Long

    'Open pdf file and creating a converter.
    nHandle = apOpen("sample1.pdf", "", "")
    Select Case nHandle
        Case ERR_OVER_MAXTHREADS
            MsgBox "Over the limit amount of threads,please waiting!"
            Exit Sub
        Case ERR_FILE_UNEXIST
            MsgBox "Source pdf file unexist!"
            Exit Sub
        Case ERR_FILE_DAMAGED
            MsgBox "Source pdf file damaged!"
            Exit Sub
        Case ERR_FILE_RESTRICTED
            MsgBox "Source pdf file restricted!"
            Exit Sub
    End Select


    'Setting the converter's propertys.
    'For more, please refer to above definitions.

    apSetProperty nHandle, AP_PROP_OUTDIR, "./demo2", 0, 0    'output directory
    apSetProperty nHandle, AP_PROP_IMAGETYPE, "", AP_IMAGE_TIFF, 0    'image type
    apSetProperty nHandle, AP_PROP_MULTIPAGES,"",1,0    'Setting multipages tiff images.

    'Get the amount of the source pdf pages
    Dim iPageCount, iPageNo As Long
    apGetProperty nHandle, AP_PROP_PAGECOUNT, "", iPageCount


    'To convert the pdf file.
    For iPageNo = 1 To iPageCount
        apConvertPage nHandle, iPageNo
    Next


    'Close pdf file and destory the converter.
    apClose (nHandle)

         Notice: For more detial samples please here to download PDF to Image SDK samples.

         (2) How to create memory stream images?
         The Pdf to Image SDK supports to convert pdf file to memory stream.
         You can save the memory stream to database, to file, or to others, etc.

         The following is a VB sample that save the memory stream to file.
     

    Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)

    Dim nHandle As Long

    'Open pdf file and creating a converter.
    nHandle = apOpen("sample1.pdf", "", "")
    Select Case nHandle
        Case ERR_OVER_MAXTHREADS
            MsgBox "Over the limit amount of threads,please waiting!"
            Exit Sub
        Case ERR_FILE_UNEXIST
            MsgBox "Source pdf file unexist!"
            Exit Sub
        Case ERR_FILE_DAMAGED
            MsgBox "Source pdf file damaged!"
            Exit Sub
        Case ERR_FILE_RESTRICTED
            MsgBox "Source pdf file restricted!"
            Exit Sub
    End Select


    'Setting the converter's propertys.
    'For more, please refer to above definitions.

    apSetProperty nHandle, AP_PROP_OUTDIR, "./demo2", 0, 0   'output directory
    apSetProperty nHandle, AP_PROP_IMAGETYPE, "", AP_IMAGE_BMP, 0   'image type

    'Get the amount of the source pdf pages
    Dim iPageCount, iPageNo As Long
    apGetProperty nHandle, AP_PROP_PAGECOUNT, "", iPageCount


    Dim sImgFile As String
    Dim nSize As Long
    Dim pImageStream As Long
    Dim bBuffer() As Byte


    'To convert the pdf file.
    For iPageNo = 1 To iPageCount
        'You can save image stream to database, to file, or to others, etc.
        'The "pImageStream" is a pointer which point to memory stream.

        apConvertPageToStream nHandle, iPageNo, pImageStream, nSize

        'Here,it saves the memory stream to bytes buffer
        ReDim bBuffer(nSize) As Byte
        CopyMemory ByVal VarPtr(bBuffer(0)), ByVal pImageStream, nSize

        'Here,it saves the buffer to file.
        If nSize > 0 Then
            sImgFile = "myimg_" + CStr(m_Pages(iPos)) + ".bmp"

            Open sImgFile For Binary As #1
            Put #1, , bBuffer
            Close #1
        End If
    Next


    'Close pdf file and destory the converter.
    apClose (nHandle)

         Notice: For more detial samples please here to download PDF to Image SDK samples.

         (3) How to increase/decrease the file size of an image?

      This section will tell you how to increase/decrease the file size of an image. The main factors on which the file size of an image defpend are listed at the following:
      Page zoom
      Resolution (DPI)
      Dimensions(width and height)
      Bits per pixel
      Compression type
      Compression quality
      So you can control image's zoom scale with adjusting the value of above parameters.

      The Page zoom is used to set zoom scale of PDF pages(10-200). For example, if it sets the page zoom as 120 or 80 and the result image is a 800x600 pixel, so the final result image is a 960x720 pixel or 640x480 pixel image. Default page zoom is 100.
      To set page zoom like this:
           apSetProperty(nHandle, AP_PROP_PAGEZOOM, "", 120, 0)

      The DPI(dots per inch) value let you specify how detialed the image is. A larger DPI value generates a more detialed image, but also will make the size of the image file larger. On the other hand, a lower DPI value generates files of smaller size, but the image is also of lower quality.The system supports from 72 to 500 DPI, default is 120 DPI.
      To set resolution like this:
           apSetProperty(nHandle, AP_PROP_XDPI, "", 150, 0)
         apSetProperty(nHandle, AP_PROP_YDPI, "", 150, 0)

      The dimensions of an image can be set in pixel. By setting the dimensions of an image, you can specify the width or height of the final result image in pixel. Increasing/Decreasing the dimensions will affect the amount of total pixel. Obviously a 1024x768 pixel image has a larger file size and more detialed than a 800x600 pixel image.
      To set the dimensions of an image like this:
           apSetProperty(nHandle, AP_PROP_XDIMENSIONS, "", 1024, 0)
         apSetProperty(nHandle, AP_PROP_YDIMENSIONS, "", 768, 0)

      Setting the color depths of an image, you can adjust the image's size as you like. Such as 1-bit(black/white), 4-bits or 8-bits grayscale instead of 24-bits true color will reduce the size of the image files, but not all formats support all color depths.
      To set bits count per pixel like this:
           apSetProperty(nHandle, AP_PROP_BITCOUNT, "", 8, 0)

      The component supports various image formats, such as BMP,JPEG,TIFF,GIF,PNG,EMF,WMF,PCX etc, but only the TIFF format supports to set compression type and the jpeg format or the tiff format which encoded by jpeg compression support to set compression quality. An appropriated compression type generates a more smaller size of image files. A larger compression quality generates a more detialed image, but also will make the size of the image file larger. On the other hand, a lower compression quality generates file of smaller size, but the image is also of lower quality. The system supports from 1 to 100 quality, default is 75.
      To set compression type like this:
    (only the type of image is tiff.)
           apSetProperty(nHandle, AP_PROP_COMPRESSION, "", AP_TIFF_COMPRESSION_LZW, 0)
      To set compression quality like this:
    (only the type of image is jpeg, or tiff which encoded by jpeg compression.)
           apSetProperty(nHandle, AP_PROP_QUALITY, "", 65, 0)
         Notice: For more detial samples please here to download PDF to Image SDK samples.

     9. Registration
         (1) Demo version
      You can free download a demo version at http://www.adultpdf.com/products/pdftoimage/index.html
     
    Limitations of the demo version:
    You are allowed to process only up to 10 pages of each pdf files simultaneously.

     
         (2) Buy now
        You can order Pdf to Image SDK online. Click here to the product site.
      。Pdf to Image SDK 10threads, only $279, buy now.
      。Pdf to Image SDK 10+threads, only $379, buy now.
      Click Client License to read the sdk license, thanks for your support.

     
         (3) Technology support
     

    Guarantee: We are committed to providing excellent products and support to our customers. If you are dissatisfied with a adultpdf product after your purchase, we will refund your money.

    Privacy Policy: We will not give, sell or otherwise transfer your personal information to third parties. Unless you ask us not to, we will send occasional email about new products and releases.

    Ongoing Open Dialog: Our customers are our most valuable resource. Please let us know how we can improve our products and we will try our best to implement your suggestions.


      If you have some questions about registering our product(s),or programe bugs,or suggestions of our product(s),or suggestions of our site,we will welcome you to contact us.
      Our sales email: sales@adultpdf.com
      Our support email: support@adultpdf.com
     

     10. Copyright&License
     
    " PDF to IMAGE SDK " Software License

    adultpdf.com Inc. PDF to Image SDK Software License

    THIS IS A CONTRACT. PLEASE READ THIS SOFTWARE LICENSE AGREEMENT CAREFULLY
    BEFORE DOWNLOADING OR USING THE SOFTWARE.

    You agree that all of the terms and conditions below apply to you and
    anyone else who uses this software, if either:

    (1)YOU COPY, INSTALL, OR USE THIS COPY OF PDF to Image SDK SOFTWARE, OR
    (2)YOU PERMIT OR ENABLE OTHERS TO COPY, INSTALL OR USE THIS PDF to Image SDK SOFTWARE.

    If you do not agree with all of the terms and conditions of this agreement,
    you must:

    (1) IMMEDIATELY CEASE USING THE SOFTWARE
    (2) DESTROY ALL COPIES OF THE SAME, INCLUDING ANY COPIES STORED ON YOUR
    HARD DRIVE AND ANY ARCHIVAL COPIES, AND

    1. License
    PDF to Image SDK software ("the Software"), documentation accompanying this
    License on any media or in any form are licensed, to you by adultpdf.com Inc.
    adultpdf.com Inc. retains title to the Software. The Software and any copies
    which this License authorizes you to make are subject to this License.

    2. Authorized Use and Restrictions
    This License allows you to install and use the Software on less than or upto
    the number of computers you have purchased the License for. If you purchased
    a License for one CPU, you may use the Software on only one machine at a time.
    A multi-processor computer is considered as one CPU for the purpose of this
    License. If you purchased many Licenses for more than one CPU, you are allowed
    to install the Software on "N" Computers where "N" is the number of licenses
    purchased. And if you purchased the server License, you may use the Software
    on anyone machine at any time and distribute the product to all your customers.

    3. Transfer
    You may not decompile, reverse engineer, disassemble, rent, lease, resell,
    loan, distribute, or produce derivative works from the Software. You may,
    however, make a one-time permanent transfer of all of your license rights to
    the Software to another party, provided that: (a) the transfer must include
    all of the Software, including all its component parts, original media,
    printed materials and this License; (b) you do not retain any copies of
    the Software, full or partial, including copies stored on a computer or
    other storage device; and (c) the party receiving the Software reads and
    agrees to accept the terms and conditions of this License.

    4. Updated Versions
    The Software may be updated from time to time adultpdf.com Inc at its sole
    discretion. You may obtain such updated versions of the Software from
    adultpdf.com Inc on the terms agreed upon by adultpdf.com Inc and you.
    Such updated versions of the Software are expected to operate more accurately
    and effectively. You acknowledge that you are responsible for downloading
    and installing such updated versions of the Software.

    5. Limitation of Liability
    UNDER NO CIRCUMSTANCES, INCLUDING NEGLIGENCE, SHALL ADULTPDF.COM INC.
    BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
    ARISING OUT OF OR RELATING TO THIS LICENSE. SOME JURISDICTIONS DO NOT
    ALLOW THE LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS
    LIMITATION MAY NOT APPLY TO YOU. IN NO EVENT, ADULTPDF.COM INC.'STOTAL
    LIABILITY TO YOU FOR ALL DAMAGES EXCEED THE AMOUNT YOU PAID TO ADULTPDF.COM
    INC. OR ITS AUTHORIZED DISTRIBUTOR.

    6. Termination
    This License is effective until terminated. Your rights under this License
    will terminate automatically without notice from adultpdf.com Inc if you
    fail to comply with any term(s) of this License. Immediately upon termination
    of this License, you shall cease all use of the Software and destroy all copies,
    full or partial, of the Software. And you will have no right to keep or use
    any copy of the Software and related user documentation for any purpose after
    termination of this Agreement.

    7. Installation
    If you requests installation services with respect to the Software,
    adultpdf.com inc will use its best efforts to install the Software on your
    server. Due to factors outside of adultpdf.com inc's control, including but
    not limited to server configuration and file availability, successful
    installation of the Software is not guaranteed. adultpdf.com inc will not be
    responsible for any losses or damages suffered by yourself as a result of the
    installation or attempted installation of the Software.

    8. Refunds
    In the event that adultpdf.com inc refunds any amounts paid by Licensee for
    the Software, Licensee understands and agrees that this Agreement and the
    Software license are terminated, and adultpdf.com inc will withdraw all Software,
    code and related documentation provided under this Agreement. Upon receipt
    of such refund, Licensee agrees that it will no longer use, display or otherwise
    control the Software, code or related documentation for which the refund
    was issued.

    9. Complete Agreement
    This License constitutes the entire agreement between the parties with respect
    to the use of the Software and supercedes all (if any) prior or contemporaneous
    understandings. No amendment to or modification of this License will be binding
    unless in writing and signed by an authorized officer of adultpdf.com Inc.

    --- end ---

     


    http://www.adultpdf.com  
    Copyright 2000-2009 by AdultPDF Technology, Inc. All rights reserved.