How to add a textfield from the form menu from code

How to add textfield without FreeTextAnnotation from my code.
The problem is that I can’t add the textfiel element that is inside the Form menu from my code. help please.


I want to specifically add that tool from code.

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:

Hi @clanagariod

We have sample code on how you add a Text Field and Text Widget programatically, which you can find here.

Best Regards,
Armando Bollain
Software Developer
PDFTron Systems, Inc.

1 Like

Thanks for your answer but the problem is that in that example the TextWidgetAnnotation is used, which when I want to modify its position or size does not let me do it. Or is there a way to modify its properties like size and position?

The TextWidget annotation has methods to set X, Y, width, and height. You can go over the documentation here:
https://www.pdftron.com/api/web/Core.Annotations.TextWidgetAnnotation.html#main

So you could set these programatically.

However, if you want an interactive way for users to resize/move the widgets, then I would suggest you use the Form Builder. This allows users to reposition and resize widgets.

While we do have a tool for adding Form Field place holders, this only works while in form mode:
https://www.pdftron.com/api/web/Core.Tools.TextFormFieldCreateTool.html#main

Best Regards,
Armando Bollain
Software Developer
PDFTron Systems, Inc.

1 Like