pdfMakeImage - convert selected pages not only to JPEG but also to PNG and BMP

<< Click to Display Table of Contents >>

Navigation:  Direct Calls to DLL >

pdfMakeImage - convert selected pages not only to JPEG but also to PNG and BMP

This function is exported by the engine DLL to make it easy to convert PDF pages into bitmap files.

No object has to be created and no initialization is required.

 

Please note that the page numbers frompage and to_page start with 1.

 

This function defined as

 

Pascal:

 

function pdfMakeImage(

 filename: PAnsiChar;

 password: PAnsiChar;

 licname, lickey: PAnsiChar;

 liccode: Cardinal;

 destpath: PAnsiChar;

 frompage, to_page: Integer;

 jpegres: Integer): Integer; stdcall;

 

filename and destpath are expected to be UTF8 encoded!

 

Better use the "W" function which supports unicode.

 

 fktpdfMakeImageW = function(filename: PWideChar;

  password: PWideChar;

   licname, lickey: PWideChar;

   liccode: Cardinal; destpath: PWideChar;

   // Use %d store page number !

   frompage, to_page: Integer; jpegres: Integer): Integer; stdcall;

 

 

Note: The unit WPViewPDF initializes the pointer wpview_....

 

C:

 

stdcall int pdfMakeImage(

 char *filename,

 char * password,

 char * licname,

 char * lickey,

 long liccode,  // only in C, in C# use int!

 char * destpath,

 int frompage,

 int to_page,

 int jpegres);

 

 

stdcall int pdfMakeImageW(

 wchar *filename,

 wchar * password,

 wchar * licname,

 wchar * lickey,

 long liccode,

 wchar * destpath,

 int frompage,

 int to_page,

 int jpegres);

 

 

C#

 

       [DllImport(DLLNAME, EntryPoint = "pdfMakeImageW",

                               CharSet = CharSet.Unicode, ExactSpelling = true,

                               CallingConvention = CallingConvention.StdCall)]

      public static extern int MakeImage(

                    string filename,

                    string password,

                    string licname,

                    string lickey,

                    int liccode, // not "long" !

                    string destpath,

                    int frompage,

                    int to_page,

                    int jpegres);

 

 

VB

 

 Declare Function pdfMakeImage Lib "wPDFViewDemo05.dll" _

                  Alias "pdfMakeJPEG" _

                  (ByVal zfilename As String, _

                   ByVal zpassword As String, _

                   ByVal zlicname As String, _

                   ByVal zlickey As String, _

                   ByVal liccode As Long, _

                   ByVal zdestpath As String, _

                   ByVal frompage As Long, _

                   ByVal To_page As Long, _

                   ByVal jpegres As LongAs Long

 

 

Parameters:

 

filename: the full path to the input PDF file. Please pass a UTF8 string unless you use the "W" function.

 

password: optional user password required to open the PDF file

 

licname, lickey, liccode: when using registered version use your license data here

 

destpath:  the path to the created image file. The placeholder %d is replaced with the page number. Please pass an UTF8 string.

 

The variable "destpath" should contain the file extension (JPG, JPEG).

 

It is also possible to create PNG files. To do so use the extension PNG.

 

frompage: the first exported page, starting with 1

 

to_page: the last exported page

 

jpegres: - low-word (0000XXXX): the resolution for the JPEG file (default = 72),

 

hi-word: various options:

 

The lower nibble of the higher word  is used to select the color depth.

It may may have this values:

 

1 : 1 bit monochrome dithered

2 : 1 bit monochrome not dithered

3 : 8 bit color

4 : 8 bit gray

otherwise: 24 bit color

 

 

The high byte of the high word is used to select the JPEG compression level (ignored for PNG)

 

 

Note: pdfMakeJPEG is still supported but should not be used anymore.

In contrast to pdfMakeImage it expects an ANSI string and not UTF8.

 

Previously characters % needed to be escaped with % in the function pdfMakeImage and pdfMakeJPEG.

We changed the code so only %d is reserved as placeholder for the page number.