PDF to Image Converter COM component user manual
Functions:
int __stdcall PDFToImageConverter(const char *szPDFFileName, const char *szOutputName,
const char *szUserPassword, const char *szOwnPassword, int xresolution, int
yresolution, int bitcount, int compression, int quality, BOOL grayscale, BOOL
multipage, int firstPage, int lastPage)
Description:
Convert Multi-page PDF file to multi-page TIFF file or single
page TIFF, BMP, EMF, PCX, JPG, PNG, GIF, TGA etc files.
Return value:
The 0 is succeed, other value indicates an error.
Parameters:
szPDFFileName | Input PDF file name |
szOutputName | Output image name |
szUserPassword | User password for input PDF file |
szOwnPassword | Owner password for input PDF file |
xresolution | Specify horizontal resolution for convert PDF to image file, (range from 1 to 1200) |
yresolution | Specify vertical resolution for convert PDF to image file, (range from 1 to 1200) |
bitcount | Set color depth for the generated
image file. The "bitcount" parameter can be one of the following values:
1: Black and White image file 8: 256 colors image file 24: 24-bits color image file |
compression | Set compression for the generated TIFF
file, this option is only available for TIFF files. The "compression"
parameter can be one of the following values: #define COMPRESSION_NONE 1 //Uncompressed TIFF file #define COMPRESSION_CCITTRLE 2 //CCITT modified Huffman RLE #define COMPRESSION_CCITTFAX3 3 //CCITT Group 3 fax encoding #define COMPRESSION_CCITTFAX4 4 //CCITT Group 4 fax encoding #define COMPRESSION_LZW 5 //Lempel-Ziv & Welch #define COMPRESSION_JPEG 7 //%JPEG DCT compression #define COMPRESSION_PACKBITS 32773 //Macintosh RLE #define COMPRESSION_CLASSF 88888888 //Create 204x98 ClassF TIFF file, Fax machine compatible format #define COMPRESSION_CLASSF196 88888889 //Create 204x196 ClassF TIFF file, Fax machine compatible format |
quality | Set quality (1 ~ 100) for the generated image file, this option is only available for JPEG files |
grayscale | Convert to 8-bit grayscale image file, this option is only available while bitcount equal 8 |
multipage | 1 is generate a multi-page TIFF file, 0 is generate a TIFF file for each page, this option is only available for TIFF format |
firstPage | First page to be converted, -1 is from the first page |
lastPage | Last page to be converted, -1 is to the last page |
Example codes:
result = PDFToImageConverter("C:\\input.pdf","C:\\output.tif",NULL,NULL,200,200,24,
COMPRESSION_PACKBITS,70,FALSE,TRUE,-1,-1);
int __stdcall PDFToImageGetPageCount(const char *szPDFFileName)
Description:
Get page number from the input PDF file.
Return value:
Page number of input PDF file
Parameters:
szPDFFileName | Input PDF file name |
Example codes:
int pageNumber = PDFToImageGetPageCount("C:\\in.pdf");
int __stdcall PDFToImageGetPageBox(const char *inputPDFFile, int page,
double *extent)
Description:
Get paper size for the input PDF file.
Return value:
The 1 is succeed, other value indicates an error.
Parameters:
inputPDFFile | Input PDF file name |
page | Page index, from 1 to max page number |
extent | An array to get the page box from a PDF file |
Example codes:
double fPageBox[4];
int result = PDFToImageGetPageBox(szPDFFileName,page,fPageBox);
printf("Page %3d box is: [%f,%f,%f,%f]\n",page,fPageBox[0],fPageBox[1],fPageBox[2],fPageBox[3]);
int __stdcall PDFToImageConverterEx(const char *szPDFFileName, const char
*szOutputName, const char *szUserPassword, const char *szOwnPassword, int
iPageSizeMode, int xDPI_Width, int yDPI_Height, int bitcount, int compression,
int quality, int grayscale, int multipage, int firstPage,int lastPage)
Description:
Convert multi-page PDF file to multi-page TIFF file or single
page TIFF, BMP, EMF, PCX, JPG, PNG, GIF, TGA etc files, you can specify page
width and page height for output image format with this function.
Return value:
The 0 is succeed, other value indicates an error.
Parameters:
szPDFFileName | Input PDF file name |
szOutputName | Output image name |
szUserPassword | User password for input PDF file |
szOwnPassword | Owner password for input PDF file |
iPageSizeMode | If this parameter is 0, this function is just same as the PDFToImageConverter function, if this parameter is 1, it is indicate the xDPI_Width and yDPI_Height parameters are page width and page height, unit is pixel |
xDPI_Width | Specify horizontal resolution or page width, it is depend on "iPageSizeMode" parameter, if iPageSizeMode equal 1 and xDPI_Width equal zero, the width of image will be calculated automatically. |
yDPI_Height | Specify vertical resolution or page height, it is depend on "iPageSizeMode" parameter, if iPageSizeMode equal 1 and yDPI_Height equal zero, the height of image will be calculated automatically. |
bitcount | Specify the color depth in the
generated image file. The "bitcount" parameter can be one of the
following values: 1: Black and White image file 8: 256 colors image file 24: 24-bits color image file |
compression | Set compression for the generated TIFF
file, this option is only available for TIFF files. The "compression"
parameter can be one of the following values: #define COMPRESSION_NONE 1 //Uncompressed TIFF file #define COMPRESSION_CCITTRLE 2 //CCITT modified Huffman RLE #define COMPRESSION_CCITTFAX3 3 //CCITT Group 3 fax encoding #define COMPRESSION_CCITTFAX4 4 //CCITT Group 4 fax encoding #define COMPRESSION_LZW 5 //Lempel-Ziv & Welch #define COMPRESSION_JPEG 7 //%JPEG DCT compression #define COMPRESSION_PACKBITS 32773 //Macintosh RLE #define COMPRESSION_CLASSF 88888888 //Create 204x98 ClassF TIFF file, Fax machine compatible format #define COMPRESSION_CLASSF196 88888889 //Create 204x196 ClassF TIFF file, Fax machine compatible format |
quality | Specify quality (1 ~ 100) in the generated image file, this option is only available for JPEG files |
grayscale | Convert to 8-bit grayscale image file, this option is only available while bitcount equal 8 |
multipage | 1 is generate a multi-page TIFF file, the 0 is generate a TIFF file for each page, this option is only available for TIFF files |
firstPage | First page to be converted, -1 is from the first page |
lastPage | Last page to be converted, -1 is to the last page |
Example codes:
int iRet = PDFToImageConverterEx("C:\\in.pdf",
"C:\\out.tif", NULL, NULL, 1, iPageWidth, iPageHeight, 24, COMPRESSION_PACKBITS,
70, TRUE, TRUE, -1, -1);
HBITMAP PDFToImageDrawToHDC(const char *szPDFFileName, HDC hDC, const
char *szUserPassword, const char *szOwnPassword, int xresolution, int
yresolution, int bitcount, BOOL grayscale, int page)
Description:
Show PDF page on screen or convert a PDF page to a HBITMAP handle.
Return value:
The HBITMAP handle for the special page. When you no longer need the bitmap,
call the DeleteObject function to delete it.
Parameters:
szPDFFileName | Input PDF file name |
hDC | Handle to the destination device context, if you set this parameter to NULL, PDFToImageDrawToHDC will create a HBITMAP only |
szUserPassword | User password for input PDF file |
szOwnPassword | Owner password for input PDF file |
xresolution | Specify horizontal resolution for convert PDF to image file, (range from 1 to 1200) |
yresolution | Specify vertical resolution for convert PDF to image file, (range from 1 to 1200) |
bitcount | Specify the color depth in the
generated image file. The "bitcount" parameter can be one of the
following values: 1: Black and White image file 8: 256 colors image file 24: 24-bits color image file |
grayscale | Convert to 8-bit grayscale image file, this option is only available while bitcount equal 8 |
page | page to be converted, page range is from page 1 to max page |
Example codes:
//Draw a PDF file to HDC directly
HBITMAP hBitmap = PDFToImageDrawToHDC("C:\\in.pdf",
GetDC(NULL), NULL,NULL,100,100,24,FALSE,1);
if(hBitmap)
DeleteObject(hBitmap);
int __stdcall PDFToImageGetPageWidth(const char *inputPDFFile, int page)
int __stdcall PDFToImageGetPageHeight(const char *inputPDFFile, int page)
Description:
Get the page width and height of a PDF page.
Return value:
The page width or page height of a PDF page.
Parameters:
inputPDFFile | Input PDF file name |
page | Page number, start from page 1 to max page |
Example codes:
int iPageWidth = PDFToImageGetPageWidth("C:\\in.pdf", 1);
int iPageHeight = PDFToImageGetPageHeight("C:\\in.pdf", 1);
int __stdcall TIFFImageGetPageCount(char *inputTIFFFile)
int __stdcall TIFFImageGetColors(char *inputTIFFFile, int page)
int __stdcall TIFFImageGetCompression(char *inputTIFFFile, int page)
int __stdcall TIFFImageSetOptions(char *inputTIFFFile, int page, int
colors, int compression)
Description:
Set options into a TIFF file
Return value:
The 1 is succeed, other value indicates an error.
Parameters:
inputTIFFFile | Input TIFF file name |
page | Specify page index, -1 is for all pages, start from 0 to max (page-1) |
colors | Specify color depth, it can be 1, 4, 8, 24 |
compression | It can be used one of following
values, #define COMPRESSION_NONE 1 /* dump mode */ #define COMPRESSION_CCITTRLE 2 /* CCITT modified Huffman RLE */ #define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax encoding */ #define COMPRESSION_CCITT_T4 3 /* CCITT T.4 (TIFF 6 name) */ #define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax encoding */ #define COMPRESSION_CCITT_T6 4 /* CCITT T.6 (TIFF 6 name) */ #define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ #define COMPRESSION_OJPEG 6 /* !6.0 JPEG */ #define COMPRESSION_JPEG 7 /* %JPEG DCT compression */ #define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ |
Example codes:
TIFFImageSetOptions("C:\\output.tif",-1,1,COMPRESSION_CCITTFAX4);
void __stdcall PDFToImageSetFileNameSuffix(const char *lpFileNameSuffix)
Description:
This function is useful to rename the output image files. For
example, "AAA.pdf" will output AAA0001.jpg, AAA0002.jpg, ... files,
Example codes:
PDFToImageSetFileNameSuffix(".%d");
AAA.pdf will output AAA.1.jpg, AAA.2.jpg, ... files,
PDFToImageSetFileNameSuffix("_%2d");
AAA.pdf will output AAA_01.jpg, AAA_02.jpg, ... files,
void __stdcall PDFToImageSetProgressCBFunc(PDFToImageProgressCBFunc
newFunc)
Description:
This function will print the progress information within PDF
to image conversion, you can display a progress information within conversion
easily.
Example codes:
typedef int (*PDFToImageProgressCBFunc)(void *, UINT Msg,
WPARAM wParam, LPARAM lParam);
int PageProgressCBFunc(void *ptrPDFName, UINT Msg, WPARAM
wParam, LPARAM lParam)
{
printf("PDFName=%s,Msg=%d,CurrentPage=%d,LastPage=%d\n",
(char*)ptrPDFName, Msg, wParam, lParam);
return 1;
}
PDFToImageSetProgressCBFunc(PageProgressCBFunc);
void __stdcall PDFToImageSetCode(const char *lpRegcode)
Description:
Register your PDF2Image SDK by the given Registration Key.
void __stdcall PDFToImageEnableErrorDiffusion(BOOL bEnable)
Description:
Enable or disable Error Diffusion arithmetic within reduce
the image's color depth.
Some examples for PDF to Image SDK:
#define COMPRESSION_NONE
1 /* dump mode */
#define COMPRESSION_CCITTRLE 2 /* CCITT modified
Huffman RLE */
#define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax
encoding */
#define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax
encoding */
#define COMPRESSION_LZW 5
/* Lempel-Ziv & Welch */
#define COMPRESSION_JPEG 7
/* %JPEG DCT compression */
#define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */
#define COMPRESSION_CLASSF 88888888 /* Convert PDF to 204x98
DPI ClassF compatible TIFF file */
#define COMPRESSION_CLASSF196 88888889
/* Convert PDF to 204x196 DPI ClassF
compatible TIFF file */
//Convert PDF file to Color TIFF file with packbits encoding,
int result = PDFToImageConverter("C:\\in.pdf","C:\\out.tif",NULL,NULL,300,300,24,COMPRESSION_PACKBITS,70,FALSE,TRUE,-1,-1);
//Convert PDF file to 204x98 ClassF TIFF file,
int result = PDFToImageConverter("C:\\in.pdf","C:\\out.tif",NULL,NULL,300,300,1,COMPRESSION_CLASSF,70,FALSE,TRUE,-1,-1);
//Convert PDF file to 204x196 ClassF TIFF file,
int result = PDFToImageConverter("C:\\in.pdf","C:\\out.tif",NULL,NULL,300,300,1,COMPRESSION_CLASSF196,
70,FALSE,TRUE,-1,-1);
//Convert PDF file to CCITTG4 TIFF file,
int result = PDFToImageConverter("C:\\in.pdf","C:\\out.tif",NULL,NULL,300,300,1,COMPRESSION_CCITTFAX4,70,FALSE,TRUE,-1,-1);
//Convert PDF file to JPG file,
int result = PDFToImageConverter("C:\\in.pdf","C:\\out.jpg",NULL,NULL,300,300,1,COMPRESSION_NONE,70,FALSE,FALSE,-1,-1);
//Convert PDF file to WMF file,
int result = PDFToImageConverter("C:\\in.pdf","C:\\out.wmf",NULL,NULL,300,300,1,COMPRESSION_NONE,70,FALSE,FALSE,-1,-1);
//Convert PDF file to EMF file,
int result = PDFToImageConverter("C:\\in.pdf","C:\\out.emf",NULL,NULL,300,300,1,COMPRESSION_NONE,70,FALSE,FALSE,-1,-1);
//Convert PDF to black and white TIFF file with CCITT Group 4 fax encoding,
without halftone technology
int result = PDFToImageConverter("C:\\in.pdf","C:\\out.tif",NULL,NULL,200,200,
1, COMPRESSION_CCITTFAX4,100,FALSE,TRUE,-1,-1);
//You can set bitcount to 8 or 24 and compression to COMPRESSION_CCITTFAX4 to
convert a color PDF file to black and white TIFF file with halftone technology
//Convert color PDF to black and white TIFF file with CCITT Group 4 fax
encoding, with halftone technology
int result = PDFToImageConverter("C:\\in.pdf","C:\\out.tif",NULL,NULL,200,200,
24, COMPRESSION_CCITTFAX4,100,FALSE,TRUE,-1,-1);
//Convert PDF to black and white TIFF file with PACKBITS encoding
int result = PDFToImageConverter("C:\\in.pdf","C:\\out.tif",NULL,NULL,200,200,
1, COMPRESSION_PACKBITS,100,FALSE,TRUE,-1,-1);
//Convert PDF to black and white TIFF file with LZW encoding
int result = PDFToImageConverter("C:\\in.pdf","C:\\out.tif",NULL,NULL,200,200,
1, COMPRESSION_LZW,100,FALSE,TRUE,-1,-1);
//Convert PDF to color TIFF file with JPEG encoding
int result = PDFToImageConverter("C:\\in.pdf","C:\\out.tif",NULL,NULL,200,200,
24, COMPRESSION_JPEG,100,FALSE,TRUE,-1,-1);
//Convert PDF to grayscale TIFF file with PACKBITS encoding, grayscale parameter
is available only when bitcount equal 8
int result = PDFToImageConverter("C:\\in.pdf","C:\\out.tif",NULL,NULL,200,200,
8, COMPRESSION_PACKBITS,100,TRUE,TRUE,-1,-1);
//Convert PDF to PNG file, set width to 1024 pixel and height to 768 pixel
int result = PDFToImageConverterEx("C:\\in.pdf","C:\\out.png",NULL,NULL,
1, 1024, 768,
24, COMPRESSION_PACKBITS,100,FALSE,TRUE,-1,-1);
//Convert PDF to JPEG file, set width to 800 pixel and height to 600 pixel
int result = PDFToImageConverterEx("C:\\in.pdf","C:\\out.jpg",NULL,NULL,
1, 800, 600,
24, COMPRESSION_PACKBITS,100,FALSE,TRUE,-1,-1);
//Convert PDF to PCX file, set width to 800 pixel and height will be calculated
automatically
int result = PDFToImageConverterEx("C:\\in.pdf","C:\\out.pcx",NULL,NULL,
1, 800, 0,
24, COMPRESSION_PACKBITS,100,FALSE,TRUE,-1,-1);
Difference between ASP interface and API interface:
ASP Functions | API Functions |
asp_PDFToImageConverter | PDFToImageConverter |
asp_PDFToImageConverterEx | PDFToImageConverterEx |
asp_PDFToImageGetPageCount | PDFToImageGetPageCount |
asp_PDFToImageGetPageWidth | PDFToImageGetPageWidth |
asp_PDFToImageGetPageHeight | PDFToImageGetPageHeight |
>>How to test PDF to Image SDK?
A: 1. Start the DOS command line window (i.e. run "cmd" command from "Start
Menu"->"Run");
2. Run the "PDF2TIF_CMD.exe" command from the command line
window (pdf2tif_cmd.exe software can be found in your PDF2Image package
uncompressed directory);
3. "PDF2TIF_CMD.exe" can be used easily, please look at
following command line examples,
For example:
C:\>pdf2tif_cmd C:\input.pdf C:\output.tif
C:\>pdf2tif_cmd C:\input.pdf C:\output.jpg
C:\>pdf2tif_cmd C:\input.pdf C:\output.bmp
C:\>pdf2tif_cmd C:\input.pdf C:\output.emf
C:\>pdf2tif_cmd C:\input.pdf C:\output.pcx
B: Double click "pdf2tif_cmd.exe" software, select one or several PDF file, and
click OK button, then your PDF file(s) will convert to multipage TIFF files.
C: Open VB or VC example project in VB or VC development environment, compile
and test PDF to Image SDK directly.
Limitations in the trial version of PDF To Image SDK:
The trial version of PDF To Image SDK contains some watermarks in the created
image files, however, these watermarks are not appear in the purchased version.
Click here
to download evaluation version of PDF to Image Converter SDK
Click here to purchase PDF
to Image Converter SDK
PDF To Image
Converter COM component user manual
ASP Example for PDF to Image Converter SDK
VC++ Example for PDF to Image Converter SDK
VB.NET Example for PDF to Image Converter SDK