Export annotations with base64 url image

WebViewer Version: “@pdftron/webviewer”: “^8.12.1”

Hello, I’m trying to export annotations that haven’t been drawn in the PDF viewer.

To do this, I converted the local image path (which worked when drawing the annotation in the viewer) to a base64 string and set it as the image data. However, even though I’m using await on the setImageData method for the StampAnnotation, the exported PDF sometimes contains “DRAFT” placeholders instead of the actual images.

What is the correct approach to exporting annotations that haven’t been added to the annotation manager or rendered in the viewer?

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 you’re trying to export annotations with image data in base64 format without them being drawn in the PDF viewer. The issue you are facing with “DRAFT” placeholders might be due to the asynchronous nature of setting image data and exporting annotations.

Some things you can try:

  • Ensure the base64 image data is correctly formatted and valid. Improperly formatted base64 strings can lead to placeholder images.

  • Make sure the setImageData method completes successfully before exporting the annotations. You can check if the promise resolves without errors.

  • Use the annotationManager to add your annotations, even if they haven’t been rendered. This can help in managing the annotation lifecycle properly.

  • Consider using annotationManager.exportAnnotations to export the annotations as XFDF, which should include your base64 image data.



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.

Hi there,

After using the setImageData API, could you please try redrawing the annotation and see if your image loads correctly?

If this does not work, could you please try updating to the latest version of WebViewer?
Please see our migration guides here:

best regards,
Kevin