Private Function GetBoxSplit_pdf(ByVal sType As String, ByVal l As Long, ByVal t As Long, ByVal r As Long, ByVal B As Long, ByVal deadline As Long) As Long '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'This function is used to get the line break from a given rectangle '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'input for this function is rectangle quardinates 'output of this function is position of word end or line end 'when we find word end it should return a no of line also '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ On Error GoTo ErrMesg Dim ssword As String Dim myrect1 As Acrobat.CAcroRect Dim PDTextSelect1 As CAcroPDTextSelect Dim AVHilite As CAcroHiliteList Dim llinecount As Long Dim AcroRect As CAcroRect Dim AcroRect1 As CAcroRect Dim lReturnValue As Long '~~~ Acrobat Object Declaration~~~~~~~~ Dim pdTextSelect As CAcroPDTextSelect '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '~~~~~~~~ Line count Variables ~~~~~~~~~~~~~~~~~~~~~ Dim lPrevLeft As Long Dim lPrevTop As Long Dim lPrevRight As Long Dim lPrevBottom As Long Dim bh As Long Dim lprevbh As Long bh = 0 lprevbh = 0 Dim lleft As Long, ltop As Long, lbottom As Long, lright As Long llinecount = 1 '~~~~~~~~ Line count Variables ~~~~~~~~~~~~~~~~~~~~~ Set AVHilite = CreateObject("AcroExch.HiliteList") Set AcroRect = CreateObject("AcroExch.Rect") 'Create a Rectangle object Set AcroRect1 = CreateObject("AcroExch.Rect") 'Convert Image coordinates into Pdf Coordinates ConvertImgToPdf l, t, r, B 'Assign the pdf co-ordinates to the rectangle object AcroRect.left = Abs(l) AcroRect.Top = Abs(t) AcroRect.Right = Abs(r) AcroRect.Bottom = Abs(B) 'Set AcroExchApp = CreateObject("AcroExch.App") pdPage.CropPage AcroRect Set pdTextSelect = pdDoc.CreateTextSelect(0, AcroRect) num = pdTextSelect.GetNumText() 'AcroExchApp.Show If (num > 0) Then iwordcount = 0 ssword = "" For iwordcount = 0 To num - 1 '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Set AVHilite = CreateObject("AcroExch.HiliteList") AVHilite.Add iwordcount, 1 Set PDTextSelect1 = pdPage.CreateWordHilite(AVHilite) Dim i2 As Integer AcroExchAVDoc.SetTextSelection PDTextSelect1 ssword = "" For i2 = 0 To PDTextSelect1.GetNumText - 1 ssword = ssword & " " & PDTextSelect1.GetText(i2) Next If ssword <> "" Then Set myrect1 = PDTextSelect1.GetBoundingRect If iwordcount = 0 Then lPrevBottom = myrect1.Bottom lPrevLeft = myrect1.left lPrevRight = myrect1.Right lPrevTop = myrect1.Top 'bh = Abs(myrect1.Top - myrect1.Bottom) End If If Abs(lPrevBottom - myrect1.Bottom) > 5 And Abs(lPrevTop - myrect1.Top) > 5 Then lprevbh = bh bh = bh + Abs(lPrevTop - lPrevBottom) llinecount = llinecount + 1 If myrect1.Bottom < B Then lReturnValue = limageheight - lPrevBottom 'GetBoxSplit = limageheight - lPrevBottom Exit For End If End If lPrevBottom = myrect1.Bottom lPrevLeft = myrect1.left lPrevRight = myrect1.Right lPrevTop = myrect1.Top End If Set pdTextSelect = Nothing Set myrect1 = Nothing Set AVHilite = Nothing '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Next End If Set AcroRect = Nothing If lReturnValue = 0 Then lReturnValue = deadline End If GetBoxSplit_pdf = lReturnValue 'GetBoxSplit = deadline Exit Function ErrMesg: GetBoxSplit_pdf = deadline MsgBox "Error while Getting text" & vbCrLf & Err.Description, vbExclamation End Function
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)