jspdf-utils 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/html-to-pdf.d.ts +9 -1
- package/dist/html-to-pdf.js +7 -1
- package/package.json +1 -1
package/dist/html-to-pdf.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Helpers that prepare an HTML element for clean, paginated PDF output
|
|
5
5
|
* via jsPDF's doc.html() renderer.
|
|
6
6
|
*/
|
|
7
|
+
import { type Options as Html2CanvasOptions } from "html2canvas-pro";
|
|
7
8
|
import jsPDF from "jspdf-with-html2canvas-pro";
|
|
8
9
|
export interface Margin {
|
|
9
10
|
top: number;
|
|
@@ -48,7 +49,7 @@ export interface PrepareResult {
|
|
|
48
49
|
/**
|
|
49
50
|
* Render an HTML element to PDF using doc.html().
|
|
50
51
|
*/
|
|
51
|
-
declare function generatePDF(doc: jsPDF, source: HTMLElement, opts?: PageOptionsInput & Pick<ImagePDFOptions, "marginContent" | "forcedPageCount" | "textBorder" | "border">): Promise<jsPDF>;
|
|
52
|
+
declare function generatePDF(doc: jsPDF, source: HTMLElement, opts?: PageOptionsInput & Pick<ImagePDFOptions, "marginContent" | "forcedPageCount" | "textBorder" | "border" | "html2canvasOptions">): Promise<jsPDF>;
|
|
52
53
|
type MarginResult = HTMLElement | string | null | undefined | void;
|
|
53
54
|
type MarginFactory = (page: number, totalPages: number) => MarginResult;
|
|
54
55
|
export interface Border {
|
|
@@ -112,6 +113,13 @@ export interface ImagePDFOptions {
|
|
|
112
113
|
* Example: 1 means only page 1 is generated/exported.
|
|
113
114
|
*/
|
|
114
115
|
forcedPageCount?: number;
|
|
116
|
+
/**
|
|
117
|
+
* Options forwarded directly to html2canvas-pro. Anything supported by
|
|
118
|
+
* html2canvas (e.g. `foreignObjectRendering`, `useCORS`, `proxy`,
|
|
119
|
+
* `windowWidth`, `logging`) can be set here. Note that `scale` and
|
|
120
|
+
* `backgroundColor` are controlled by this library and will be overridden.
|
|
121
|
+
*/
|
|
122
|
+
html2canvasOptions?: Partial<Html2CanvasOptions>;
|
|
115
123
|
}
|
|
116
124
|
/**
|
|
117
125
|
* Render an HTML element as an image-based PDF. Each page is a rasterized
|
package/dist/html-to-pdf.js
CHANGED
|
@@ -5497,7 +5497,11 @@ async function Rg(t, A, e = {}) {
|
|
|
5497
5497
|
n.margin.right,
|
|
5498
5498
|
n.margin.bottom,
|
|
5499
5499
|
n.margin.left
|
|
5500
|
-
]
|
|
5500
|
+
],
|
|
5501
|
+
// jspdf's bundled html2canvas type is older than html2canvas-pro's
|
|
5502
|
+
// (e.g. onclone signature differs). The runtime call forwards
|
|
5503
|
+
// identically, so cast through unknown.
|
|
5504
|
+
html2canvas: e.html2canvasOptions
|
|
5501
5505
|
});
|
|
5502
5506
|
});
|
|
5503
5507
|
} finally {
|
|
@@ -5893,6 +5897,7 @@ async function Gg(t, A = {}) {
|
|
|
5893
5897
|
);
|
|
5894
5898
|
try {
|
|
5895
5899
|
const a = await ae(o, {
|
|
5900
|
+
...A.html2canvasOptions,
|
|
5896
5901
|
scale: s,
|
|
5897
5902
|
backgroundColor: null
|
|
5898
5903
|
}), { jsPDF: c } = await import("./jspdf.es.min-BDu0IqVE.js").then((p) => p.j), l = Jn(a, n, B, s), g = Math.ceil(a.height / l.contentHeightPx), Q = _n(
|
|
@@ -5948,6 +5953,7 @@ async function Mg(t, A = {}) {
|
|
|
5948
5953
|
);
|
|
5949
5954
|
try {
|
|
5950
5955
|
const a = await ae(o, {
|
|
5956
|
+
...A.html2canvasOptions,
|
|
5951
5957
|
scale: s,
|
|
5952
5958
|
backgroundColor: null
|
|
5953
5959
|
}), c = Jn(a, n, B, s), l = Math.ceil(a.height / c.contentHeightPx), g = _n(
|
package/package.json
CHANGED