it’s not working. please check this there any incorrect. there is not arguments
Imports System.IO
Imports iText.Kernel.Pdf
Imports iText.Forms
Imports iText.Forms.Fields
Public Class FillPdfForm
Public Sub FillForm()
’ Replace these paths with your actual PDF file paths
Dim src As String = “D:\Downloads\Electronic Check Copy Req.pdf”
Dim dest As String = “D:\Downloads\Electronic Check Copy Req.pdf”
Using pdf As New PdfDocument(New PdfReader(src), New PdfWriter(dest))
Dim form = PdfAcroForm.GetAcroForm(pdf, True)
' Replace field names and values as per your requirement
form.GetField("name").SetValue("James Bond")
form.GetField("language").SetValue("English")
form.GetField("experience1").SetValue("Off")
form.GetField("experience2").SetValue("Yes")
form.GetField("experience3").SetValue("Yes")
form.GetField("shift").SetValue("Any")
form.GetField("info").SetValue("I was 38 years old when I became an MI6 agent.")
' Optional: Flatten the form fields to make them read-only
' form.FlattenFields()
End Using
Console.WriteLine("PDF form filled successfully!")
End Sub
Imports System.IO
Imports iText.Kernel.Pdf
Imports iText.Forms
Imports iText.Forms.Fields
Public Class FillPdfForm
Public Sub FillForm()
' Replace these paths with your actual PDF file paths
Dim src As String = "D:\Downloads\Electronic Check Copy Req.pdf"
Dim dest As String = "D:\Downloads\FilledForm.pdf"
Using pdf As New PdfDocument(New PdfReader(src), New PdfWriter(dest))
Dim form = PdfAcroForm.GetAcroForm(pdf, True)
' Replace field names and values as per your requirement
form.GetField("name").SetValue("James Bond")
form.GetField("language").SetValue("English")
form.GetField("experience1").SetValue("Off")
form.GetField("experience2").SetValue("Yes")
form.GetField("experience3").SetValue("Yes")
form.GetField("shift").SetValue("Any")
form.GetField("info").SetValue("I was 38 years old when I became an MI6 agent.")
' Optional: Flatten the form fields to make them read-only
' form.FlattenFields()
End Using
Console.WriteLine("PDF form filled successfully!")
End Sub
End Class