SaveDIBAsColorPDFPage

 

            SaveDIBAsColorPDFPage(hDIB As Long, szDllName As String,
                        dwCompression As Long, nLossRatio As Long) As Boolean

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 method

Saving a page to an already existing PDF file (opened using LoadPDFIntoDIB) 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 GetLastPDFError() for the error code.

Sample Code

'initialize the library

PDFOCX1.InitPDF()

'create the PDF file and writes the first mandatory objects

PDFOCX1.CreatePDF(m_PDFFile)

'Load the number of images from the TIFF file

ImageCount = 0

ImageCount = Tiff1.GetNumberOfImagesInTiffFile(m_TIFFFile)

For i = 0 To ImageCount - 1

hDIB = Tiff1.LoadTiffIntoDIB(m_TIFFFile, i, False)

'save the image using the FLAG_FILTER_FLAT_DECODE (512) compression

PDFOCX1.SaveDIBAsColorPDFPage(hDIB, "BITIFF.DLL", 512, -1)

Next i

PDFOCX1.FinishPDF()

PDFOCX1.ReleasePDF