Bulk stamping same stamp on all pages intermittently skips a page (commonly page 2) and generates incorrect XFDF

WebViewer Version: 11.7.1

Do you have an issue with a specific file(s)? NO
Can you reproduce using one of our samples or online demos? NO
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? NO
Is your issue related to annotations? Yes

Please give a brief summary of your issue:
When a user adds the same stamp multiple times across all pages (bulk stamping), the stamp is visually added to all pages in the viewer. However, intermittently one page (most often page 2) does not receive the correct XFDF data.

Please describe your issue and provide steps to reproduce it:
Load a multi-page PDF document (10+ pages increases repro chance)

  1. Add a stamp on the current page
  2. Choose “Apply stamp to all pages”
  3. Repeat the same action multiple times using the same stamp
  4. Reload the document or fetch annotations from backend

Expected Result

  • The stamp should be added to every page

  • Each page should generate correct XFDF

  • No pages should be skipped

Actual Result

  • One page (most commonly page 2) is missing the stamp

  • XFDF for that page is not generated or is incorrect

  • Viewer UI may temporarily show the stamp, but it is not persisted

 if (selectedOption === 'all') {
     saveStamp = false;
     $('.common-loading-spinner-text').text('Please do not close your browser or press the back button until the stamps has been fully added to the document.');
     $('.common-loading').show();
     let bulkRequest = [];
     isBulkStamping = true;
     let lastPageNumber = 0;
     try {
         for (let pageNumber = 1; pageNumber <= totalPages; pageNumber++) {
             lastPageNumber = pageNumber;
             let annot;

             if (pageNumber === currentPage) {
                 annot = lastStamp;
             } else {
                 annot = annotationManager.getAnnotationCopy(lastStamp);
                 annot.PageNumber = pageNumber;
                 annotationManager.addAnnotation(annot);
             }

             const annotData = await annotationManager.exportAnnotationCommand();

             bulkRequest.push({
                 caseId: $('#Id').val(),
                 contentItemId: $('#ContentItemId').text().trim(),
                 annotData,
                 annotType: 'Stamp',
                 annotId: annot.Id,
                 pageNumber: pageNumber - 1,
                 currentUserId: userID,
                 status: 'None',
             });

             if (bulkRequest.length === 15 || lastPageNumber === totalPages) {
                 PartialApryse.ApplyBulkStamp([...bulkRequest]);
                 bulkRequest = [];
             }
         }
         documentViewer.refreshAll();
         isBulkStamping = false;
         await annotationManager.exportAnnotationCommand();
     } catch (err) {
         console.error('Bulk stamping failed:', err);
         $('.common-loading').hide();
     } finally {
         $('.common-loading').hide();
     }
 }

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

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 you’re experiencing an issue with bulk stamping where the XFDF data is not correctly applied to all pages, especially when using the “Apply stamp to all pages” feature. This could be due to asynchronous handling of annotations or a race condition in processing the XFDF data.

Some things you can try:

  • Ensure that the annotation manager is properly handling asynchronous operations, particularly with the drawAnnotations function, which is now asynchronous in recent versions.

  • Consider adding a delay or ensuring that each stamping operation is completed before starting the next one to avoid race conditions.

  • Verify that the XFDF data is being correctly generated and saved after each stamping action by checking the returned XFDF string for completeness.

  • Use the AnnotationManager to programmatically verify that each page has the stamp after applying it to all pages.

  • Make sure there are no errors in the console that might indicate issues with the stamping process.



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.

Hello @rishumishra2001,

Thank you for posting on our forum.

The option to “choose ‘apply stamp to all pages’” is not a part of the default configuration of WebViewer. Is this a custom UI element that you have implemented? If so, feel free to provide the relevant code snippets of how it is implemented.

Based on the current code snippet, it looks like the intention is that for each page, the stamp is added to the document and then exported via exportAnnotationCommand to be pushed to your database “or bulkRequest”. If I have misunderstood your desired workflow, feel free to provide an exact step-by-step of the workflow you are trying to achieve.

To investigate further, please confirm the following

  1. Why are you calling exportAnnotationCommand after addAnnotation? Typically when exporting annotations via exportAnnotationCommand, we recommend calling it within an annotationChanged event callback, as that event is triggered after the annotation would be registered in the annotationManager and added to the document.
  2. What is the use case behind the code snippet? Is this meant to be an auto-save feature when adding stamps to all pages in the document?
  3. Regarding “Viewer UI may temporarily show the stamp, but it is not persisted”, what do you mean by “persisted”? Are you downloading the document via our default “download” button? Or importing all of the XFDF into a document? Please provide a demo video and/or screenshots with the expected vs. actual behavior.
  4. Are you able to reproduce this issue with our latest release (Version 11.9.1)?
  5. Does this issue occur when exporting all of the annotations via exportAnnotations rather than exportAnnotationCommand? https://sdk.apryse.com/api/web/Core.AnnotationManager.html#exportAnnotations

Best Regards,
Jacob Romano Carlsen
Web Development Support Engineer
Apryse Software Inc.