L_PdfCompInsertMRC
#include "l_bitmap.h"
#include "lpdfComp.h"
L_LCMRC_API L_INT L_PdfCompInsertMRC(hDocHandle, pBitmap, pPDFOptions)
LCPDF_HANDLE hDocHandle; |
/* handle to an existing PDF document */ |
pBITMAPHANDLE pBitmap; |
/* pointer to a bitmap handle */ |
LPPDFCOMPOPTIONS pPDFOptions; |
/* pointer to the PDFCOMPOPTIONS structure */ |
(Document Required) Segments the specified image using MRC segmentation, compresses it, and inserts the image in the PDF file in memory.
Parameter |
Description |
hDocHandle |
Handle to an existing PDF document. This handle is obtained by calling the L_PdfCompInit function. |
pBitmap |
Pointer to the bitmap handle that references the image to be inserted in the PDF file. |
pPDFOptions |
Pointer to the PDFCOMPOPTIONS structure that contains options used to write the image to the PDF file in memory. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
To insert the bitmap without using MRC segmentation, use L_PdfCompInsertNormal.
This function calls the pPDFCOMP_IMAGECALLBACK to allow the user to accept or reject the addition of any segment to the PDF document.
Required DLLs and Libraries
LCMRC For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
See Also
Functions: |
|
Topics: |
|
|
Example
This example inserts an image to pdf document and uses the MRC to make a proper segment for this image , in this sample we don't need to add Back ground segment.
L_INT PdfCompImageCallBack(LCPDF_HANDLE hDocument, L_INT nPage, LPSEGMENTINFO pSegment, L_VOID* pUserData) { UNREFERENCED_PARAMETER(hDocument); UNREFERENCED_PARAMETER(nPage); UNREFERENCED_PARAMETER(pUserData); if(pSegment->uSegmentType == SEGMENT_BACKGROUND) return FAILURE; else return SUCCESS; } L_INT PdfCompInsertMRCExample(L_VOID) { L_INT nRet; BITMAPHANDLE hBitmap; LCPDF_HANDLE hDocument; PDFCOMPOPTIONS PDFOptions; PDFCOMPRESSION pdfComp; nRet = L_LoadBitmap (TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 16\\Images\\Image.CMP"), &hBitmap, sizeof(BITMAPHANDLE), 0, ORDER_RGB, NULL, NULL); if(nRet != SUCCESS) { return nRet; } nRet = L_PdfCompInit (&hDocument, (pPDFCOMP_IMAGECALLBACK)PdfCompImageCallBack, NULL); if(nRet != SUCCESS) { return nRet; } pdfComp.uStructSize = sizeof( pdfComp ); pdfComp.dwFlags = PDFCOMP_1BITCOMPTYPE_ENABLED | PDFCOMP_2BITCOMPTYPE_ENABLED | PDFCOMP_PICTURECOMPTYPE_ENABLED ; pdfComp.comp1Bit = PDFCOMP_1BITCOMPTYPE_JBIG2; pdfComp.comp2Bit = PDFCOMP_2BITCOMPTYPE_ZIP; pdfComp.compPicture = PDFCOMP_PICTURECOMPTYPE_JPEG; pdfComp.nQFactor = 50; nRet = L_PdfCompSetCompression( hDocument, &pdfComp ); if(nRet != SUCCESS) { L_PdfCompFree (hDocument); return nRet; } PDFOptions.uStructSize = sizeof(PDFCOMPOPTIONS); PDFOptions. dwFlags = PDFCOMP_FAVOR_ONEBIT | PDFCOMP_WITH_BACKGROUND ; PDFOptions.imageQuality = PDFCOMP_IMAGEQUALITY_USER; PDFOptions.outputQuality = PDFCOMP_OUTPUTQUALITY_USER; PDFOptions.uCleanSize = 7; PDFOptions.uBackGroundThreshold = 15; PDFOptions.uCombineThreshold = 100; PDFOptions.uSegmentQuality = 50; PDFOptions.uColorThreshold = 25; nRet = L_PdfCompInsertMRC(hDocument, &hBitmap, &PDFOptions); if(nRet != SUCCESS) { L_PdfCompFree (hDocument); return nRet; } nRet = L_PdfCompWrite(hDocument, TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 16\\Images\\Output.pdf")); L_PdfCompFree (hDocument); return nRet; }