How to specify a font family (e.g. 'Times') for a form field created by TextFormFieldCreateTool or other tool

WebViewer Version:
8.4.1

Do you have an issue with a specific file(s)? -
Can you reproduce using one of our samples or online demos? -
Are you using the WebViewer server? No
Does the issue only happen on certain browsers? -
Is your issue related to a front-end framework? Yes
Is your issue related to annotations? Yes

Please give a brief summary of your issue:
We want to configure TextFormFieldCreateTool tool to create form field which uses ‘Times New Roman’ font by default. No API was found in the documentation for that.
We only need that for NEW fields added by PDFTron Webviewer tools.
PS. TypeScript solution is preferred.

Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)

Please provide a link to a minimal sample where the issue is reproducible:

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hello ydanneg,

You can use the .setStyles() API found here: PDFTron WebViewer Class: TextFormFieldCreateTool

Let me know if this works for you!

Best regards,
Tyler Gordon
Web Development Support Engineer
PDFTron

“Example of valid properties: StrokeColor, TextColor, FillColor, FontSize, Opacity, StrokeThickness, Precision, Scale, OverlayText, Style and Dashes”

What is the property to set a font name?

Hello ydanneg,

It looks like you cant set the font directly on the tool, instead you can set the font of the TextWidget when its added to the document like so:

  const fontOptions = {
    name: 'Times',
    size: 12,
  }
  const font = new Annotations.Font(fontOptions)

  annotationManager.addEventListener('annotationChanged', (annotations, action, info) => {
    if (action === 'add' && annotations[0] instanceof Annotations.TextWidgetAnnotation) {
      annotations[0].set({'font': font})
    }
  })

Best regards,
Tyler Gordon
Web Development Support Engineer
PDFTron