I am using the Acrobat SDK to extract text from pdf files.
This works quite well.
My code does not extract the text from comments though.
Is it possible to extract the text from comments/annotations using the Acrobat SDK?
I know I can use iTextSharp and it works well, but I only want to use a single library.
Code below:
Public Shared Function AdobePdfParse(strFileName As String, strTxtFromFile As String) As String
'Note: A Reference to the Adobe Library must be set in Tools|References!
'Note! This only works with Acrobat Pro installed on your PC, will not work with Reader
Dim AcroApp As CAcroApp, AcroAVDoc As CAcroAVDoc, AcroPDDoc As CAcroPDDoc
Dim AcroHiliteList As CAcroHiliteList, AcroTextSelect As CAcroPDTextSelect
Dim PageNumber, PageContent, i, j, iNumPages
Dim strResult As String
AcroApp = CreateObject("AcroExch.App")
AcroAVDoc = CreateObject("AcroExch.AVDoc")
If AcroAVDoc.Open(strFileName, vbNull) <> True Then Exit Function
AcroPDDoc = AcroAVDoc.GetPDDoc
iNumPages = AcroPDDoc.GetNumPages
Dim intfirst As Integer = 1
For i = 0 To iNumPages - 1
PageNumber = AcroPDDoc.AcquirePage(i)
PageContent = CreateObject("AcroExch.HiliteList")
If PageContent.Add(0, 9000) <> True Then Exit Function
AcroTextSelect = PageNumber.CreatePageHilite(PageContent)
' The next line is needed to avoid errors with protected PDFs that can't be read
On Error Resume Next
For j = 0 To AcroTextSelect.GetNumText - 1
strTxtFromFile = strTxtFromFile & AcroTextSelect.GetText(j)
Next (j)
Next i
AcroAVDoc.Close(bNoSave:=0)
AcroApp = Nothing
AcroAVDoc = Nothing
'Return sbTxtFromFile
Return strTxtFromFile
End Function