pdfMakeImageExt

<< Click to Display Table of Contents >>

Navigation:  Direct Calls to DLL > pdfMakeImage - convert selected pages to bitmaps >

pdfMakeImageExt

This special version of pdfMakeImage has been created to read PDF from a COM stream and write the created bitmap data to a COM stream.

 

function pdfMakeImageExt(

 InStream  : IUnknown;  // Load PDF from here.

 OutStream : IUnknown;  // Save the image data here

 filename  : PWideChar; // Not used if InStream was specified

 PageCount : PInteger;  // Receives count of pages in PDF

 password  : PWideChar; // Password for the PDF

 licname, lickey: PWideChar; liccode: Cardinal;

 destpath: PWideChar; // Not used except to specify format

 // if OutStream was specified (Use %d store page number)

 frompage, to_page: Integer; // If OutStream was specified only one page is written

 imageres   : Integer;  // The resolution, i.e. 200

 // or HighWord=Height, LowWord=Width of desired image size.

 // The bitmap will fit into the specified rectangle

 imagemode : Integer // This is a bit field to specify the color and stream mode.

 ): Integer; stdcall;

 

or, in C++ syntax:

 

stdcall int pdfMakeImageExt(

 IUnknown InStream,  // Load PDF from here.

 IUnknown OutStream,  // Save the image data here

 wchar *filename, // Not used if InStream was specified

 int *PageCount,  // Receives count of pages in PDF

 wchar *password, // Password for the PDF

 wchar *licname,

 wchar *lickey,

 int liccode,

 wchar *destpath,; // Not used except to specify format

 // if OutStream was specified (Use %d store page number)

 int frompage,

 int to_page: Integer, // If OutStream was specified only one page is written

 int imageres,  // The resolution, i.e. 200

 // or HighWord=Height, LowWord=Width of desired image size.

 // The bitmap will fit into the specified rectangle

 int imagemode // This is a bit field to specify the color and stream mode.

 );

 

All strings must be passed as wide character strings.

 

 

Example - C++Builder

 

 res := pdfMakeImageExt(

            InStream,

            OutStream,

            PWideChar(filename),

            @PageCount,

            '',

            WPViewPDF_LicName,

            WPViewPDF_LicKey,

            WPViewPDF_LicCode,

            PWideChar(os),

            IOParams.ImageIndex+1,

            IOParams.ImageIndex+1,

            ImageResolution,

            0

            );

 

 

 

imageres is the desired resolution for the created image, i.e. 200.

 

You can also specify the desired width and height of the bitmap inpixels. To do so, pass the width as high-word and the height as low-word of parameter imageres.

 

imagemode is used to specify the color depth.

 1 - select BW Images

 2 - Grayscale Image - default 24 bit color Image

 otherwise a 24 bit color Image will be created

 

Bit 17-24 is used to specify the  JPEG Compression (0-100)

 

Use the value 8 to create a gray scale image, 0 to create 24bit color.

 

 

InStream can be nil or a IStream reference.  If it is a stream reference the PDF data will be loaded from there.

 

OutStream can be nil or a IStream reference. In the latter case the created bitmap data is written there. Filename must be still provided to make it possible to determine the desired image format. Possible file extensions are .BMP, .JPG, .PNG.

 

If the parameter imagemode is set to 32768 multiple images can be exported to a single stream with one call. The stream will use this header data:

 INTEGER = total size of data (=StreamSize)

 INTEGER = Count of Images

 INTEGER[Count of Images] = Offset of each Image

 

 If the Offset is 0, the image is empty.

 The Length of the image data can be calculated as difference of the following, or, for the last image, the stream size