Word wrap within textannotation widget

PDF.js Express Version

Detailed description of issue
I’m trying to add text content to a TextWidgetAnnotation (programatically, no UI) and I can’t seem to find any functionality to make the text wrap when the widget box ends. For now, I iterate through the widgets, find the field I want to fill with a "if (field.name === …) " and set the value use field.setValue.

Expected behaviour
{Provide a screenshot or description of the expected behaviour}

Does your issue happen with every document, or just one?
Any document

Link to document
{Provide a link to the document in question if possible}

Code snippet
async function addStandardFields(docViewer, annotManager) {
if (templateInfo) {
const documentURL = templateInfo.downloadUrl;
let contents = await fileService.getExternalFileBlob(documentURL);

    await docViewer.loadDocument(contents);

    await docViewer.getAnnotationsLoadedPromise();
    await mergeService.mergeDataIntoForm(annotManager.getFieldManager(), {
        jobsId: jobId,
        filePath: templateInfo.fullPath


function addFields(commentWidgets, Annotations, annotManager) {
if (wvinstance.current) {
commentWidgets.forEach((annot: Annotations.TextWidgetAnnotation, index) => {
const field = annot.getField();
if (field.name === “interior-comments”) {
field.setValue(props.data?.interiorComments ?? “”);
if (field.name === “exterior-comments”) {
field.setValue(props.data?.exteriorComments ?? “”);


const handleSubmit = async () => {
const {docViewer, annotManager, Tools, Annotations} = wvinstance.current;
const fieldManager = annotManager.getFieldManager();

await addStandardFields(docViewer, annotManager);

const annotationList = annotManager.getAnnotationsList();

const signatureWidgets = annotationList.filter(el => el.fieldName?.includes("signature"));
const comments = annotationList.filter(el => el.fieldName?.includes("comments"));
addSignatures(signatureWidgets, Annotations, annotManager);
addFields(comments, Annotations, annotManager);

const xfdf = await annotManager.exportAnnotations({links: false, widgets: false});


Thank you

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: