Copy link to clipboard
Copied
Hi all. I work on an application that applies annotations to PDF documents.
After loading the PDF viewer we call the annotation manager API's addAnnotations method. The promise eventually errors out with the following error (see image below) "Error: std::bad_alloc,std::bad_alloc", and we can see that some of the annotations have not been added.
Some important context is that we are attempted to add up to 500 different annotations to a given PDF. From my (admittedly basic) tests, the limit appears to be around 120 annotations before the error happens.
I have attached an image of the browser's console. This is in Google Chrome.
Is there a known maximum number of annotations that is supported? I did not see a number mentioned in the docs.
I tried chaining the addAnnotation promises in batches of 100 at a time, but the error still occured.
Very interested to hear if anyone has also had this same issue, or if any Adobe devs would like to take a look that would be excellent and greatly appreciated.
Thanks for reading.
1 Correct answer
You'd listen for the CURRENT_ACTIVE_PAGE event.
Copy link to clipboard
Copied
I wanted to also attach a copy of the adobe log message that was being sent in the network event:
[
{
"level":"error",
"message":"Reached maximum number of initial events",
"sessionId":"ba2ede6a-5049-4d09-b823-7a61c1b9fd77",
"viewSDKAppVersion":"3.27.1_3.2.10-ea8924cb",
"tenantId":"--private--",
"callingApp":"dc-view-sdk",
"externalUserId":"--private--",
"clientId":"--private",
"client_timestamp":"2025-03-06T14:13:53.240Z",
"context":"Analytics"
}
]
Copy link to clipboard
Copied
Try adding them in batches of 10.
Copy link to clipboard
Copied
Try adding them in batches of 10.
By Joel Geraci
Hi Joel, thanks for your reply. Batches of 10 unfortunately ends up in the same result. I've attached my console log, after each promise resolved I printed the batch index. I also tried batches of 5, and despite getting a little further this time, still ends up failing.
Copy link to clipboard
Copied
Further to add, even running one at a time I am unable to get even to 200 annotations added. Strangely batches of 5 seems to get the furthest at around ~200 annotations.
Copy link to clipboard
Copied
I'm guessing there are just too many updates that are trying to redraw the PDF for Embed to handle. I'm going to suggest something a bit unorthodox. Try adding only the annotations that are for the currently viewed page, listen to the page change event (whatever that's called) and then add the annotations for that page.
Copy link to clipboard
Copied
Hi Joel, I had been thinking along a similar line, however from reading the docs I didn't see an event regarding a page change. Could you point me in the direction?
In our application the user can either interact with a non-adobe component, and this can navigate to a page using the `gotoLocation` method on the viewer API. But obviously they can also interact with the Adobe client itself, which we don't have any awareness of currently.
Copy link to clipboard
Copied
You'd listen for the CURRENT_ACTIVE_PAGE event.
Copy link to clipboard
Copied
Thank you Joel, this has worked perfectly. I really appreciate your help!
Copy link to clipboard
Copied
Yeah. I was guessing that the redraw buffer was getting over run. Glad you have a solution.

