Crionics LOGO

TUTORIALS

 

 Template Tutorial:
Filling form fields

As easy as 1, 2, 3...

 

Generate the template PDF

Usually, you only need to take this step one time. Once you create the template, it can be reused as many times as necessary.

  • Using your favorite PDF generation tool, create your PDF template.
  • Add PDF form fields for the areas in the document that will be generated dynamically.

 

Recover the form field

Form fields are identified in a document by their name.
To recover a form field you only need to specify its name - as follows:

// Load the template module:
TemplateModule template = doc.getTemplateModule();

// Recover the form field named "Text":
AbstractField myField= template.getField("Text");

 

Update the form field

Each type of form field has different setters depending on its nature.
In the example above, the form field named "Text" is a text field. Updating its value is as simple as the following code:

// Update the form field:
((TextField) myField).setValue("My Text Field new value");

When working with template documents, it is common to leave them unchanged and to save the updated version to a new destination:

// Save the modified document to a new location:
doc.saveAs("generatedDocument.pdf");
doc.close();


© 2000-2007 Crionics Inc. Report issues with this page