i have written below code to extract tool tip from PDF which is using itextsharp dll but getting error as I am unable to import itextsharp dll.
Code:
Try
'Create DataTable
Dim dt As New System.Data.DataTable()
dt.Columns.Add(“FieldName”, GetType(String))
dt.Columns.Add(“Tooltip”, GetType(String))
dt.Columns.Add(“Value”, GetType(String))
'Read PDF
Dim reader As New iTextSharp.text.pdf.PdfReader(in_PdfPath)
Dim form As iTextSharp.text.pdf.AcroFields = reader.AcroFields
If form Is Nothing OrElse form.Fields Is Nothing OrElse form.Fields.Count = 0 Then
reader.Close()
out_dtFields = dt
Return
End If
'Loop all fields
For Each fieldName As String In form.Fields.Keys
Dim tooltip As String = ""
Dim value As String = ""
'Value
value = form.GetField(fieldName)
'Tooltip in /TU
Dim item As iTextSharp.text.pdf.AcroFields.Item = form.GetFieldItem(fieldName)
If item IsNot Nothing Then
Dim merged As iTextSharp.text.pdf.PdfDictionary = item.GetMerged(0)
If merged IsNot Nothing Then
Dim tu As iTextSharp.text.pdf.PdfString = merged.GetAsString(iTextSharp.text.pdf.PdfName.TU)
If tu IsNot Nothing Then
tooltip = tu.ToUnicodeString()
End If
End If
End If
'Add to dt
Dim row As System.Data.DataRow = dt.NewRow()
row("FieldName") = fieldName
row("Tooltip") = tooltip
row("Value") = If(value, "")
dt.Rows.Add(row)
Next
reader.Close()
out_dtFields = dt
Catch ex As Exception
Dim dtErr As New System.Data.DataTable()
dtErr.Columns.Add(“FieldName”, GetType(String))
dtErr.Columns.Add(“Tooltip”, GetType(String))
dtErr.Columns.Add(“Value”, GetType(String))
Dim r As System.Data.DataRow = dtErr.NewRow()
r("FieldName") = "ERROR"
r("Tooltip") = ex.ToString()
r("Value") = ""
dtErr.Rows.Add(r)
out_dtFields = dtErr
End Try
It take PDF path as input and give tool tip into excel.
Error:
No compiled code to run
error BC30002: Type ‘iTextSharp.text.pdf.PdfReader’ is not defined. At line 8
error BC30002: Type ‘iTextSharp.text.pdf.AcroFields’ is not defined. At line 9
error BC30002: Type ‘iTextSharp.text.pdf.AcroFields.Item’ is not defined. At line 27
error BC30002: Type ‘iTextSharp.text.pdf.PdfDictionary’ is not defined. At line 29
error BC30002: Type ‘iTextSharp.text.pdf.PdfString’ is not defined. At line 31
error BC30451: ‘iTextSharp’ is not declared. It may be inaccessible due to its protection level. At line 31 Variable ‘iTextSharp.text.pdf.PdfReader’ is missing. Please use Data Manager to recreate it.
i-485.pdf (1.1 MB)
Main.xaml (10.5 KB)
I am using i-485 pdf for testing.
basically I need to extract all tool tip present in pdf into excel /datatable.
any one please suggest, how to do

