Have text updated on the page programmatically (Click outside the box simulation action)

WebViewer Version:

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

Please give a brief summary of your issue:
Downloaded file doesn’t include all edited text

Please describe your issue and provide steps to reproduce it:
So basically when editing some text on the page, if I click on the download button without clicked outside the text edit box before, the edited text is not available in the downloaded document and in best case, only a short part of edited text is included. So I’d like to find a way to save those changes by simulating the outside clic action.

Steps to reproduce :

  • Select the “PDF Text Editing feature”
  • Edit some text content by adding content, don’t click outside the box
  • Click the download button
  • The edited text or part of it is not available in the downloaded button

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

Please select the “PDF Text Editing feature”

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 seems like the issue you’re experiencing is related to the text editing session not being finalized, which means that the changes aren’t being committed to the document before you initiate the download. This can happen if the text editing box is still active when you try to download the file. To resolve this, you need to programmatically simulate the action of clicking outside the text box to ensure that all edits are committed before the download.

Some things you can try:


  • Use the commitContent method from the Annotations.TextWidgetAnnotation class to programmatically commit the text changes.

  • Listen for the download button click event and ensure that any active text editing session is finalized before proceeding with the download.

  • Invoke the documentViewer.refreshAll() method to ensure that all changes are rendered before downloading.




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

Hello Salva,

This is the expected behavior. When a user is typing, we just interact with the html and no data is sent to the worker so it cannot be saved. You could use the stopContentEditing API in this case before saving to stop focusing on the edit box. This should allow the changes to be saved.

Here is some sample code:

// get the Id of the content box that is currently selected
const contentEditManager = instance.Core.documentViewer.getContentEditManager();
const annotation = instance.Core.annotationManager.getSelectedAnnotations()[0];
const contentBoxId = annotation.getCustomData("contentEditBoxId");

// get the content box by Id and stop editing
const box = contentEditManager.getContentBoxById(contentBoxId);
box.stopContentEditing();
​
// now download the PDF

Best Regards,
Darian

2 Likes