This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Create and Fill Form Fields in PDF with Java  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Introduction

Form Fields allow users to interactive with PDF file by filling in information or making selections, which can then be submitted for processing. The types of PDF form fields including text input field, check box, radio button, combo box, list box, and button. This tip will show how to create and fill such form fields in PDF programmatically in Java using Free Spire.PDF for Java API.

Adding Dependencies

For maven projects, we could easily add dependencies to the Free Spire.PDF for Java API by adding the following code in pom.xml:

(The latest version of Free Spire.PDF for Java in maven repository can be found here.)

For common Java projects, download the latest version of Free Spire.PDF for Java, (download link), then add Spire.Pdf.jar from the lib folder into your project.

Using the code

The following table shows the form fields and the corresponding class in Free Spire.PDF for Java API:

Form FieldClass
Text input fieldPdfTextBoxField
Check boxPdfCheckBoxField
List boxPdfListBoxField
Combo boxPdfComboBoxField
Radio buttonPdfRadioButtonListField
ButtonPdfButtonField


  • Creating form fields


  • To create a form field, we first need to create an instance of the corresponding class, and then add it to the form fields collection using the add method of class PdfFormFieldCollection.


  • Filling form fields


  • To fill form fields, we need to determine the types of the fields. Below example shows how to determine the types of form fields and fill the form fields with value.


    Additional information

    There are many more manipulations (such as change appearance, clone, delete, move to another location and add JavaScript) we could do with PDF form fields except that introduced above. If interested, you can give it a try by yourself.
     
    My pie came with a little toothpic holding up this tiny ad:
    how do I do my own kindle-like thing - without amazon
    https://coderanch.com/t/711421/engineering/kindle-amazon
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!