vb.net - 使用 VB 使用 Acrobat SDK (Interop.Acrobat.dll) 从 pdf 中提取注释。网
问题描述
我正在使用 Acrobat SDK 从 pdf 文件中提取文本。
这工作得很好。
我的代码并没有从评论中提取文本。
是否可以使用 Acrobat SDK 从评论/注释中提取文本?
我知道我可以使用 iTextSharp 并且效果很好,但我只想使用一个库。
下面的代码:
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
解决方案
推荐阅读
- android - 在 ConstraintLayout 中换行
- mongodb - 在返回的查询文档中添加排名系统?
- sql - 使用 SQL 进行词条匹配
- scala - 在 Spark 代码(Scala)中生成序列号的最佳选择是什么?
- android - 页面重新加载时未调用 Android Webview onReceivedTitle
- angularjs - 如何访问参数以获取 $resource 中的单个对象?
- canvas - 如何删除画布中形状之间出现的不需要的白线
- java - 如何在 jmeter webdriver 采样器中使用我自己创建的 Java jar?
- css - 如何从样式组件中扩展(继承)全局 CSS 类
- ios - 从 Firebase 存储下载并查看 ios 中的文档