PDFCompInsertMRC Example for Visual C++ 5.0 and later
void CTestPDFCOMP::OnInsertWithtMRC()
{
CoInitialize(NULL);
HRESULT hr = CoCreateInstance(CLSID_LEADRaster, NULL, CLSCTX_ALL, IID_ILEADRaster, (void**)&m_pltRaster);
if (FAILED(hr))
return;
hr = CoCreateInstance(CLSID_LEADRasterIO, NULL, CLSCTX_ALL, IID_ILEADRasterIO, (void**)&m_pltRasterIO);
if (FAILED(hr))
{
m_pltRaster->Release();
m_pltRaster = NULL;
return;
}
hr = CoCreateInstance(CLSID_LEADPDFCompressor, NULL, CLSCTX_ALL, IID_ILEADPDFCompressor, (void**)&m_pltPDFComp);
if (FAILED(hr))
{
m_pltRasterIO->Release();
m_pltRasterIO = NULL;
m_pltRaster->Release();
m_pltRaster = NULL;
return;
}
m_pltRasterIO->LoadArray (m_pltRaster,"c:\\Image.cmp",0,0,1);
m_pltPDFComp->EnableMethodErrors = FALSE;
m_pltPDFComp->PDFCompInit (TRUE);
m_pltPDFComp->PDFCompSetCompression ( (PDFCOMP_1BIT_COMPRESSION_TYPE_ENABLED | PDFCOMP_2BIT_COMPRESSION_TYPE_ENABLED | PDFCOMP_PICTURE_COMPRESSION_TYPE_ENABLED), PDFCOMP_1BIT_COMP_TYPE_JBIG2, PDFCOMP_2BIT_COMP_TYPE_ZIP, PDFCOMP_PICTURE_COMP_TYPE_JPEG, 50);
m_pltPDFComp->ImageQuality = PDFCOMPIMAGEQUALITY_USER;
m_pltPDFComp->OutputQuality = PDFCOMPOUTPUTQUALITY_USER;
m_pltPDFComp->Flags = PDFCOMP_FAVOR_ONE_BIT | PDFCOMP_WITHBACKGROUND
m_pltPDFComp->CleanSize = 7;
m_pltPDFComp->SegmentQuality = 50;
m_pltPDFComp->ColorThreshold = 25;
m_pltPDFComp->BackGroundThreshold = 15;
m_pltPDFComp->CombineThreshold = 100;
m_pltPDFComp->PDFCompInsertMRC (m_pltRaster);
m_pltPDFComp->PDFCompWrite ("c:\\output.pdf");
m_pltPDFComp->PDFCompFree ();
m_pltRasterIO->Release();
m_pltRaster->Release();
m_pltPDFComp->Release();
m_pltPDFComp = NULL;
m_pltRasterIO = NULL;
m_pltRaster = NULL;
}
void CRasterPDFCompSink::onPDFCompEvent(long nPage)
{
if (nPage == 1)
{
CString str ;
str.Format(TEXT("Left Value of Segment 0 = = %d "), m_pltPDFComp-> MRCSegmentInfo.SegmentLeft ) ;
MessageBox(str);
str.Format(TEXT("Right Value of Segment 0 = = %d "), m_pltPDFComp-> MRCSegmentInfo.SegmentRight ) ;
MessageBox(str);
str.Format(TEXT("Top Value of Segment 0 = = %d "), m_pltPDFComp-> MRCSegmentInfo.SegmentTop ) ;
MessageBox(str);
str.Format(TEXT("Bottom Value of Segment 0 = = %d "), m_pltPDFComp-> MRCSegmentInfo.SegmentBottom ) ;
MessageBox(str);
str.Format(TEXT("Segment type of Segment 0 = = %d "), m_pltPDFComp-> MRCSegmentInfo.SegmentType ) ;
MessageBox(str);
str.Format(TEXT("Color Count of Segment 0 = = %d "), m_pltPDFComp-> MRCSegmentInfo.SegmentColorsCount ) ;
MessageBox(str);
COLORREF Color;
m_pltPDFComp-> MRCSegmentInfo.get_SegmentColors (0, &Color);
str.Format(TEXT("Color 0 of Segment 0 = = %d "), Color ) ;
MessageBox(str);
}
m_pltPDFComp->EnableAddSegment = TRUE;
}