0

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 each chart and would like to insert these in the corresponding PDF page, e.g. chart comment 34 goes in PDF page containing chart 34.

My current approach is to insert these comments manually, one by one, using the comment tool in Adobe Acrobat Pro. This takes time as you can imagine.

Is there a way to speed up this process? Ideally, I would have all my comments in a spreadsheet (and less ideal, Python) with the chart code next to it. Then, comments would be written to the PDF.

Any ideas how this can be done?

StatsScared
  • 517
  • 6
  • 20

1 Answers1

0

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

ASH
  • 20,759
  • 19
  • 87
  • 200