Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.10.24
LEADTOOLS Mixed Raster Content (MRC) C DLL Help

L_PdfCompInsertMRC

Show in webframe

#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
LCPDF
LCENC
LCZIB
LTSGM

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:

L_PdfCompInsertNormal, pPDFCOMP_IMAGECALLBACK

Topics:

Creating a Compressed PDF File

 

PDF Compressor Functions: Creating a File

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.

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName


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 (MAKE_IMAGE_PATH(TEXT("Image1.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, MAKE_IMAGE_PATH(TEXT("Output.pdf")));

   L_PdfCompFree (hDocument);
   return nRet;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.