Customizing text editor possible?

Product: @pdftron/webviewer
Product Version: ^10.12.0

I would like to store last selected values in the text editor dialog. Is this even possible with the current SDK?

I want customers to have the same settings as they set up when last using the dialog. Want to be able to “remember” font size, font style (bold/italic/strikethrough…)…

1 Like

Hello, I’m AiRon, an automated tech support bot :robot:
While you wait for one of our customer support representatives, I can help you with your question.


It is possible to customize and extend the behavior of the text editor in WebViewer to remember user preferences such as font size and style. However, the SDK does not directly provide a built-in feature to store these settings across sessions. You would need to implement a mechanism to save and retrieve these preferences, possibly using local storage or a database.

Some things you can try:

  • Use the setTextAttributes API in the Core.ContentEdit namespace to programmatically set font styles when initializing the text editor.

  • Store user preferences in local storage or a similar persistent storage solution when the user sets their preferences.

  • On initialization of the text editor, read the stored preferences and apply them using the setTextAttributes API.



Here are some resources that might help you:


Hopefully, this helps you solve your problem while you wait for a human to get back to you.

1 Like

Hi there,

When you mean the text editor, are you referring to annotation style popup?

If you change this via the tool menu, instead of directly from the annotation, then this will be saved in your browser.

best regards,
Kevin

1 Like

Kevin,

Yes, that dialog is what I need to get data out of last selections used.

regards,
David

1 Like

Hi there,

Thank you for confirming,

Like mentioned above, the changes in the tool’s settings in the toolbar will persist in the local storage:

best regards,
Kevin

1 Like

Kevin,

That does not work for me as I need to store this for user in their external session information. If they log in on a different machine and use the app it still needs to show them last settings used :slight_smile:

Is there any way to get this information out of the dialog when user changes these settings?

regards,
David

1 Like

Hi there,

This would be difficult/messy to achieve, but you could try the following:

  1. Have a save button for when the user completes a document session. This is needed as there is no event for when a tool’s settings have changed.
  2. Go through every tool available for the user - the full list can be found here:
    Apryse WebViewer Namespace: Tools
  3. Save the tool’s ‘defaults’ property. This contains the tool’s style settings. Note that some tools have more settings than others.
    For instance, free-text tool has a fontSize object whereas a rectangle create tool does not:
    Apryse WebViewer Class: FreeTextCreateTool
    Apryse WebViewer Class: GenericAnnotationCreateTool
  4. When a user loads their document session, set every tool’s defaults with the saved style settings.

Best regards,
Kevin

1 Like

Kevin,

I already have save button for storing PDF changes back,
but the selections need to be saved as soon as they change.

But I also think there is a bigger problem here.
At the moment I don’t see text dialog saving any data back to the local storage at all.
It’s always default settings that I set for the FreeTextTool.

I even used setInterval to read data storage 10/second and there are no changes made when
user is interacting with the dialog components. Not even before dialog is disposed.

regards,
David

1 Like

Hi there,

Thank you for your response,

I already have save button for storing PDF changes back,
but the selections need to be saved as soon as they change.

Unfortunately, we do not have an event that tracks if a user has made changes to the style options. This can be tracked potentially with a visibilityChanged event when the style modal popup is closed:
https://sdk.apryse.com/api/web/UI.html#event:visibilityChanged

But I also think there is a bigger problem here.
At the moment I don’t see text dialog saving any data back to the local storage at all.
It’s always default settings that I set for the FreeTextTool.

Are you able to reproduce this on the showcase demo?

Or the legacyUI sample page here: JavaScript PDF Viewer Demo

If not, could you please try updating to the latest version and see if that resolves the issue?

best regards,
Kevin

1 Like

Kevin,

Investigating this and will let you know once I figure out what is going on :slight_smile:

I found this event in the docs on documentViewer:

toolUpdated

Triggered when the tool styles or tool name have changed

Is this not supposed to be triggered when something is changed in the tools?

But I don’t see this event triggered at all too.

David

1 Like

Hi there,

It looks like toolsUpdated event is being triggered when changing the styles of the tool:

I would recommend you update to the latest version and see if that resolves your issue.

Best regards,
Kevin