Some test text!


Create text field and text widget annotation using JavaScript

To create a new text field with multi-line required flags and a text widget annotation.

.then(instance => {
  const { annotManager, Annotations } = instance;
  const { WidgetFlags } = Annotations;

  // myBtn is your own custom button
  document.getElementById('myBtn').addEventListener('click', () => {

    // set flags for multiline and required
    const flags = new WidgetFlags();
    flags.set('Multiline', true);
    flags.set('Required', true);

    // create a form field
    const field = new Annotations.Forms.Field("some text field name", {
      type: 'Tx',
      defaultValue: "some placeholder default text value",

    // create a widget annotation
    const widgetAnnot = new Annotations.TextWidgetAnnotation(field);

    // set position and size
    widgetAnnot.PageNumber = 1;
    widgetAnnot.X = 100;
    widgetAnnot.Y = 100;
    widgetAnnot.Width = 50;
    widgetAnnot.Height = 20;

    //add the form field and widget annotation

Create fillable PDF forms
Full sample code demonstrating how to add form fields to a PDF. Fields are first added as annotations and then converted to interactive form fields. Add signatures, text fields, checkboxes.

Available widget flags are:

  • ReadOnly
  • Required
  • NoExport
  • Multiline
  • Password
  • NoToggleToOff
  • Radio
  • PushButton
  • Combo
  • Edit
  • DoNotScroll
  • RadiosInUnison

Get the answers you need: Support


Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.