Skip to content

Commit

Permalink
Use HTMLCanvasElement.toBlob() unconditionally in PDFPrintService
Browse files Browse the repository at this point in the history
The fallback is very old code, and according to the MDN compatibility data `HTMLCanvasElement.toBlob()` should be available in all browsers that we support now: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob#browser_compatibility
  • Loading branch information
Snuffleupagus committed Aug 23, 2024
1 parent 584fef5 commit 502a429
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions web/pdf_print_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,9 @@ class PDFPrintService {
useRenderedPage() {
this.throwIfInactive();
const img = document.createElement("img");
const scratchCanvas = this.scratchCanvas;
if ("toBlob" in scratchCanvas) {
scratchCanvas.toBlob(function (blob) {
img.src = URL.createObjectURL(blob);
});
} else {
img.src = scratchCanvas.toDataURL();
}
this.scratchCanvas.toBlob(blob => {
img.src = URL.createObjectURL(blob);
});

const wrapper = document.createElement("div");
wrapper.className = "printedPage";
Expand Down

0 comments on commit 502a429

Please sign in to comment.