Some test text!

menu
Date pickerkeyboard_arrow_down

Date picker

For form fields that expect a date to be input, WebViewer provides an interactive date picker widget to select a date from a calendar. Users can still type the date like before, but the date field can now also be populated by using the calendar.

The calendar will automatically set the correct date format for the field so the user doesn't need to worry about entering the date in a specific format.

date-picker-demo.gif

linkFilling date field programmatically

Just like other PDF form fields, the date field can also be filled programmatically using the fieldManager or using the Annotations.DatePickerWidgetAnnotation instance

Here is an example of filling date field programmatically:

WebViewer(...)
  .then(instance => {
    const { annotManager, docViewer } = instance;
    docViewer.on('annotationsLoaded', () => {
      // replace with id of date field in your document
      const dateFieldId = 'DatePicker_1';
      const field = annotManager.getFieldManager().getField(dateFieldId);
      field.setValue('6/15/20');

      const widget = field.widgets[0];
      widget.getDatePicker().show(); // open date picker widget
      widget.getDatePicker().setDate('6/17/20');


      field.setValue('6/7/20');
      widget.refreshDatePicker(); // refresh widget
    });
    // ...
});

linkDatepicker Internationalization

The default i18n configuration format looks like this:

WebViewer(...)
  .then(instance => {
    const { Annotations } = instance;
    const { DatePickerWidgetAnnotation } = Annotations;

    DatePickerWidgetAnnotation.datePickerOptions.i18n = {
      previousMonth : 'Previous Month',
      nextMonth     : 'Next Month',
      months        : ['January','February','March','April','May','June','July',
        'August','September','October','November','December'],
      weekdays      : ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday',
        'Saturday'],
      weekdaysShort : ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
    }

    DatePickerWidgetAnnotation.datePickerOptions.firstDay = 0;
    DatePickerWidgetAnnotation.datePickerOptions.isRTL = false;
   // ...
});

You must provide 12 months and 7 weekdays (with abbreviations). Always specify weekdays in this order with Sunday first. You can change the firstDay option to reorder if necessary (0: Sunday, 1: Monday, etc). You can also set isRTL to true for languages that are read right-to-left.

Get the answers you need: Support

close

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.

Join our live demo to learn about use cases & capabilities for WebViewer

Learn more
close