How to import itextsharp Namespace

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

Hi @c3f1e68294fdcf4a1f0a817ca

Have you added itextsharp dependency in your project?

If not, please try adding below:

itextsharp.7z (2.0 MB)

and then try adding required namespaces

Hi,

Can you try to install iTextSharp library from nuget.org feed (https://api.nuget.org/v3/index.json) via ManagePackage?

Sample
Sample20260121-1.zip (915.1 KB)

note: Add nuget feed at settings of Studio in advance.

Regards,

@c3f1e68294fdcf4a1f0a817ca

Go to manage packages and search of itextsharp and see which package has the required extension libraries and install the same

Also instead of itextsharp ..try using itext7 as that is the latest version with LTS support

Cheers

Hi I tried your running sample that you have attached and it working but company will not allow using 3rd party package. cant we add official itextsharp nuget by downloading from official website and keeping that into local and then add it.

how to use itext7, there is no official package

Hi @sonaliaggarwal47

This is not a code issue. UiPath can’t find the iTextSharp library.

Install iTextSharp via Manage Packages (search for iTextSharp / iTextSharp.LGPLv2.Core), save and restart Studio.
Set Invoke Code language to VB and add Imports iTextSharp.text.pdf.

After the package is installed, PdfReader, AcroFields, etc. will be recognized and the code will run.

@c3f1e68294fdcf4a1f0a817ca

Try with gpt give the itextsharp code and ask for itext7

cheers