PDFCompInsertMRC Example for Visual Basic
Dim WithEvents LeadPDFComp As LEADPDFCompressor
Dim Factory As New LEADRasterFactory
Dim Raster As LEADRaster
Dim RasterIO As New LEADRasterIO
Dim gszLic As String
Private Sub Click_Click()
gszLic = "LEADTOOLS OCX Copyright (c) 1991-2005 LEAD Technologies, Inc."
Set LeadPDFComp = New LEADPDFCompressor
Set Raster = Factory.CreateObject("LEADRaster.LEADRaster", gszLic)
RasterIO.Load Raster, "C:\Image.CMP", 0, 0, 1
LeadPDFComp.EnableMethodErrors = False
LeadPDFComp.PDFCompInit True
LeadPDFComp.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
LeadPDFComp.ImageQuality = PDFCOMPIMAGEQUALITY_USER
LeadPDFComp.OutputQuality = PDFCOMPOUTPUTQUALITY_USER
LeadPDFComp.CleanSize = 7
LeadPDFComp.Flags = PDFCOMP_FAVOR_ONE_BIT + PDFCOMP_WITHBACKGROUND
LeadPDFComp.SegmentQuality = 50
LeadPDFComp.ColorThreshold = 25
LeadPDFComp.BackGroundThreshold = 15
LeadPDFComp.CombineThreshold = 100
LeadPDFComp.PDFCompInsertMRC Raster
LeadPDFComp.PDFCompWrite "C:\Output.pdf"
LeadPDFComp.PDFCompFree
End Sub
Private Sub LeadPDFComp_OnPDFCompEvent(ByVal nPage As Long)
If nPage = 1 Then
MsgBox "Left Value of Segment 0 = " + Str(LeadPDFComp.MRCSegmentInfo.SegmentLeft)
MsgBox "Right Value of Segment 0 = " + Str(LeadPDFComp.MRCSegmentInfo.SegmentRight)
MsgBox "Top Value of Segment 0 = " + Str(LeadPDFComp.MRCSegmentInfo.SegmentTop)
MsgBox "Bottom Value of Segment 0 = " + Str(LeadPDFComp.MRCSegmentInfo.SegmentBottom)
MsgBox "Segment type of Segment 0 = " + Str(LeadPDFComp.MRCSegmentInfo.SegmentType)
MsgBox "Color Count of Segment 0 = " + Str(LeadPDFComp.MRCSegmentInfo.SegmentColorsCount)
MsgBox "Color 0 of Segment 0 = " + Str(LeadPDFComp.MRCSegmentInfo.SegmentColors (0))
End If
LeadPDFComp.EnableAddSegment = True
End Sub