From 502a429e3e87495dfd93da3cbeb19ca93614c536 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 23 Aug 2024 13:39:32 +0200 Subject: [PATCH] Use `HTMLCanvasElement.toBlob()` unconditionally in `PDFPrintService` 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 --- web/pdf_print_service.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/web/pdf_print_service.js b/web/pdf_print_service.js index 78ea670a7..7017345a0 100644 --- a/web/pdf_print_service.js +++ b/web/pdf_print_service.js @@ -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";