XDoc.PDF
Features
Tech Specs
How-to VB.NET
Pricing
How to Start Convert PDF Work with PDF Modules PDF Document PDF Pages Text Image Graph & Path Annotation, Markup & Drawing Redaction Security Digital Signature Forms Watermark Bookmark Link File Attachment File Metadata Printing Work with Other SDKs Barcode read Barcode create OCR Twain

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


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





Look for HTML5 PDF Editor?

EdgePDF: ASP.NET PDF Editor is the best HTML5 PDF Editor and ASP.NET PDF Viewer based on XDoc.PDF, JQuery, HTML5. It supports ASP.NET MVC and WebForms projects.


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