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 = 1DoWhileNot EOF(1)
    Line Input #1, Data
    Data = Application.WorksheetFunction.Trim(Data)
sData = Split(Data, " ")

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

Close #1Call CopyOver

EndSubSub CopyOver()

Dim Rng As Range, cell As Range
Dim rw AsLongSet Rng = Worksheets("Sheet1").Range("B1:B20")
rw = 1ForEach cell In Rng

If Left(cell.Value, 4) = "test"ThenIf Left(cell.Value, 4) = "test"And cell.Offset(0, -1) = "application:"ThenGoTo 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 + 2EndIfEndIfNextEndSub

Before:

enter image description here

After:

enter image description here

Post a Comment for "Systematically Annotate A Pdf"