Running an export causes a warning about eventual deprecation, is this known or maybe already fixed?
jspdf.es.min.js?8baf:197 [Deprecation] Synchronous
[Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
I assume the warning comes when loading images from a URL? The thing is, that the API of addImage is synchronous for historic reasons and we therefore need to make synchronous requests. There is an easy workaround, though, by preloading the image and passing it e.g. as data url to the addImage method. We might consider making addImage optionally async.
Yeah that could be it.
In my export, I use addImage after taking a snapshot of a given element using html2canvas, like so:
const canvas = await html2canvas(element);
this.addImage(
Therefore I don't see a preload solution for my use case but it was a good idea nevertheless.
You could convert the canvas element to a data url: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL
Hmm the warning still popups
```
this.document.addImage(
(image as HTMLCanvasElement).toDataURL(),
"png",
position.x,
position.y,
dimension.width,
dimension.height,
);
Mmh that's odd... could you debug a little and try to find out why?
This issue is stale because it has been open 90 days with no activity. It will be closed soon. Please comment/reopen if this issue is still relevant.
Most helpful comment
I assume the warning comes when loading images from a URL? The thing is, that the API of
addImageis synchronous for historic reasons and we therefore need to make synchronous requests. There is an easy workaround, though, by preloading the image and passing it e.g. as data url to theaddImagemethod. We might consider makingaddImageoptionally async.