GemBox Support Forum

Changing the value of a PdfTextField


I tried to extend the Fill in Form example in order to set the Value of a PdfTextField.

Just added the snipplet to show the name as text:

Dim i As Integer = 0
For Each field As PdfField In document.Form.Fields
    If TypeOf field Is PdfTextField Then
            Dim textField As PdfTextField = field
            textField.Value = textField.Name & "_" & i
            i = i + 1
    End If

However i always get the error:

System.TypeInitializationException: “The type initializer for ' ’ threw an exception.”
Inner exception
FileNotFoundException: Could not load file or assembly ‘System.IO.Packaging, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’. Das System kann die angegebene Datei nicht finden.

Could you please extend the example to show how the change the text of a PdfTextField?

Thanks and kind regards,

Hi Sven,

I was unable to reproduce your issue.

I tried the snippet code you provided, the following is the screenshot of the resulting PDF that I get:

Can you please send us your VS project so that we can reproduce your issue and investigate it?


Hello Mario,

I uploaded it to github. See https://github.com/Kyubu-77/FillTextBox_ErrorCase

thanks for the quick response and kind regards,

Hallo Mario,

ok i got it working. The “Could not load file or assembly ‘System.IO.Packaging, Version=” occures then you are using TargetFramework netcoreapp3.1 but referencing the GemBox.Pdf for net35. Referencing the GemBox.Pdf of the /netcoreapp3.1 folder solves it.

thanks and kind regards,