VB.NET PDF: How to HTML5 PDF Viewer PDF Create PDF Export File & Page Process PDF Read PDF Write Form Process Document Protect Annotation & Drawing PDF Print WPF PDF Viewer Work with Other SDKs Barcode Read Barcode Create OCR Twain
Data: Auto Fill-in Field Data
  |  
Home ›› XDoc.PDF ›› VB.NET PDF: Auto Fill-in Field Data

VB.NET PDF - Fill-in Field Data Automatically in VB.NET


How to Automatically Fill in Field Data to PDF in VB.NET Class




Overview



RasterEdge XDoc.PDF SDK package provides PDF field processing features for your VB.NET project. On this VB.NET tutorial, you will learn how to fill-in field data to PDF automatically in your VB.NET application. Following VB.NET sample code can help you have a quick evaluation of it.




How to VB.NET: Auto Fill-in Field Data to PDF



Add necessary references:


  RasterEdge.Imaging.Basic.dll


  RasterEdge.Imaging.Basic.Codec.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XDoc.Raster.dll


  RasterEdge.XDoc.Raster.Core.dll


  RasterEdge.XDoc.PDF.dll


Use corresponding namespaces;


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.PDF;


Following code sample shows how to automatically fill in field data to PDF file. Please note: position or name should be provided for filling in field data.




Dim inputFilePath As String = Program.RootPath + "\\" + "1_AF.pdf"
Dim outputFilePath As String = Program.RootPath + "\\" + "output.pdf"

Dim fields As List(Of BaseFormField) = PDFFormHandler.GetFormFields(inputFilePath)

Dim cnt As Integer = 0
For Each field As BaseFormField In fields

    If TypeOf field Is AFCheckBox Then
        ' fill a CheckBox field, set state to ON
        Dim input As AFCheckBoxInput = New AFCheckBoxInput(True)
        PDFFormHandler.FillFormField(inputFilePath, field.Name, input, outputFilePath + cnt.ToString() + ".pdf")
    ElseIf TypeOf field Is AFRadioButton Then
        ' fill a RadioButton field, set state to ON 
        Dim input As AFRadioButtonInput = New AFRadioButtonInput(True)
        PDFFormHandler.FillFormField(inputFilePath, field.Name, input, outputFilePath + cnt.ToString() + ".pdf")
    ElseIf TypeOf field Is AFTextBox Then
        ' fill a TextBox field, change content to "Hello World"
        Dim input As AFTextBoxInput = New AFTextBoxInput("Hello World!")
        PDFFormHandler.FillFormField(inputFilePath, field.Name, input, outputFilePath + cnt.ToString() + ".pdf")
    ElseIf TypeOf field Is AFListBox Then
        ' fill a ListBox field, selete the 3rd item (with index value 2)
        Dim input As AFListBoxInput = New AFListBoxInput(New Integer() {2})
        PDFFormHandler.FillFormField(inputFilePath, field.Name, input, outputFilePath + cnt.ToString() + ".pdf")
    ElseIf TypeOf field Is AFComboBox Then
        ' fill a BomboBox field, selete the 3rd item (with index value 2)
        Dim input As AFComboBoxInput = New AFComboBoxInput(2)
        PDFFormHandler.FillFormField(inputFilePath, field.Name, input, outputFilePath + cnt.ToString() + ".pdf")
    End If

    cnt += 1
Next