SaveDIBAsColorPDFPage

 

BOOL CCreatePDF::SaveDIBAsColorPDFPage( HANDLE hDIB,
LPCSTR   szDllName,
DWORD   dwCompression,
int              nLossRatio);

Description

Save a DIB as a color page in the PDF file. The page is reformatted to fit the image. The TIFF DLL is loaded dynamically when it is needed from the path specified in szDllName.

The PDF must have already been created using the CreatePDF function

Saving a page to an already existing PDF file (opened using pdf OpenPDFFile) will append the new page to the end of the PDF file.

Parameters

 

Long

hDIB

The DIB to be saved  NOTE:  The color depth of the DIB must be 1, 8, or 24 bits

String

szDllName

Some compressions require functions from other DLLs.

For the FLAG_FILTER_CCITT_FAX_DECODE compression, the path of the BITIFF.DLL must be passed, and the FLAG_FILTER_DCT_JPEG_DECODE compression requires providing the path of the BIJPEG.DLL. See the compression table below.

Long

dwCompression

This specifies the compression method used to compress the images. The following compressions are available:

 

FLAG_FILTER_NO_COMPRESSION

FLAG_FILTER_FLAT_DECODE

FLAG_FILTER_RUNLENGTH_DECODE (8-bit images only)

FLAG_FILTER_CCITT_FAX_DECODE (1-bit images only)

FLAG_FILTER_DCT_JPEG_DECODE (24-bit images only)

 

See the compression table below for more information.

Long

nLossRatio

Only used when the FLAG_FILTER_DCT_JPEG_DECODE compression is selected, it is ignored for other compression methods.  Can be any value from 0 to 100.

 

 

The table below shows the possible compression types, and the correct parameters for each type:

 

The compression to use (see PDF Read/Write)

Compatible color modes

Compression ID

(dwCompression

parameter)

DLL Path (szDllName parameter)

Loss Ratio (nLossRatio parameter)

FLAG_FILTER_NO_COMPRESSION

Any color mode

32

Empty string (unused)

-1 (unused)

FLAG_FILTER_FLAT_DECODE

Any color mode

512

Empty string (unused)

-1 (unused)

FLAG_FILTER_RUNLENGTH_DECODE

8-bit only

1024

Empty string (unused)

-1 (unused)

FLAG_FILTER_CCITT_FAX_DECODE

1-bit only

2048

<install path>\BiTiff.dll

-1 (unused)

FLAG_FILTER_DCT_JPEG_DECODE

24-bit only

4096

<install path>\BiJpeg.dll

Can be any value from 0 to 100.

 

Return values

TRUE on success, FALSE if any error occured. Call PDF_GetLastError() for the error code.