Skip to content Skip to sidebar Skip to footer

Systematically Annotate A PDF

I have a large PDF file with several hundred pages. Each page of the PDF contains a chart and also includes a unique identifier (the chart number). I have individual comments for e

Solution 1:

Can you convert the PDF to a text file, save it, import it, and do a search for the 'comments'? I'm not sure what the logic would be, and you didn't post any code here, but my code below will iterate through a text file and find all incidents of a string, let's say it is called 'test' and 'application'.

Sub ReadFile()
Open "C:\Users\rshuell001\Desktop\sample.txt" For Input As #1
lRow = 1

Do While Not EOF(1)
    Line Input #1, Data
    Data = Application.WorksheetFunction.Trim(Data)
sData = Split(Data, " ")

    With Sheet1
        lColumn = 1
        For intCount = LBound(sData) To UBound(sData)
            .Cells(lRow, lColumn) = sData(intCount)
            lColumn = lColumn + 1
        Next intCount
    End With
    lRow = lRow + 1

Loop

Close #1

Call CopyOver

End Sub

Sub CopyOver()

Dim Rng As Range, cell As Range
Dim rw As Long
Set Rng = Worksheets("Sheet1").Range("B1:B20")
rw = 1
For Each cell In Rng

If Left(cell.Value, 4) = "test" Then
    If Left(cell.Value, 4) = "test" And cell.Offset(0, -1) = "application:" Then
    GoTo ExitPoint
    Else
    Worksheets("Sheet2").Cells(rw, "A") = cell.Value
    Worksheets("Sheet2").Cells(rw + 1, "A") = cell.Offset(1, 0)
    Worksheets("Sheet2").Cells(rw + 2, "A") = cell.Offset(3, 0)
    Worksheets("Sheet2").Cells(rw + 2, "B") = cell.Offset(3, 1)
ExitPoint:
    rw = rw + 2
    End If
End If
Next


End Sub

Before:

enter image description here

After:

enter image description here


Post a Comment for "Systematically Annotate A PDF"