Serialize annotation with image

WebViewer Version: 8.2

I’m trying to serialize a custom annotation (after following the PDFTron) and in the draw() method of the annotation I need to perform a drawImage() in the given context because I need to show an image, the problem is, when I try to call super.serialize() to serialize the other (not custom) properties, it gives the following error:

Uncaught (in promise) DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.

I’ve run some tests and the error comes when I add said drawImage() into the context, otherwise it does not give any problems. In fact I don’t need to save the image in the serialized annotation, but I do need to show it.

Is there any way to tell the super.serialize() to skip the image? Or to show it but without having to serialize it? Or maybe remove the image temporarily from the canvas while serializing and then adding it again to show it? As I said, I’m calling the super because I do need the other properties it serializes.

Thanks

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hi Smargret
Thanks for contacting us for support.
You need to add the crossOrigin attribute to whatever image you’ve drawn otherwise the browser will give that error Allowing cross-origin use of images and canvas - HTML: HyperText Markup Language | MDN

Best Regards
Jack

Oh true!
My bad, thank you :+1:t3: