Skip to content
Snippets Groups Projects
Unverified Commit 883c20ef authored by metabase-bot[bot]'s avatar metabase-bot[bot] Committed by GitHub
Browse files

asynchronously load libraries for png and pdf exports (#41036) (#41050)

parent 66a9000e
No related branches found
No related tags found
No related merge requests found
import { css } from "@emotion/react";
import html2canvas from "html2canvas";
export const SAVING_DOM_IMAGE_CLASS = "saving-dom-image";
export const SAVING_DOM_IMAGE_HIDDEN_CLASS = "saving-dom-image-hidden";
......@@ -22,6 +21,7 @@ export const saveChartImage = async (selector: string, fileName: string) => {
node.classList.add(SAVING_DOM_IMAGE_CLASS);
const { default: html2canvas } = await import("html2canvas");
const canvas = await html2canvas(node, {
useCORS: true,
});
......
import html2canvas from "html2canvas";
import jspdf from "jspdf";
import { color } from "metabase/lib/colors";
import { SAVING_DOM_IMAGE_CLASS } from "./save-chart-image";
......@@ -17,6 +14,7 @@ export const saveDashboardPdf = async (
return;
}
const { default: html2canvas } = await import("html2canvas");
const image = await html2canvas(node, {
useCORS: true,
onclone: (doc: Document, node: HTMLElement) => {
......@@ -35,6 +33,7 @@ export const saveDashboardPdf = async (
const pdfWidth = imageWidth;
const pdfHeight = imageHeight + 80;
const { default: jspdf } = await import("jspdf");
const pdf = new jspdf({
unit: "px",
hotfixes: ["px_scaling"],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment