jspdf-utils 0.4.0 → 0.4.1
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 +10 -8
- package/package.json +1 -1
package/dist/html-to-pdf.d.ts
CHANGED
|
@@ -132,9 +132,17 @@ declare function generateImagePDF(source: HTMLElement, opts?: PageOptionsInput &
|
|
|
132
132
|
* visual output of renderImagePDF.
|
|
133
133
|
*/
|
|
134
134
|
declare function generateImages(source: HTMLElement, opts?: PageOptionsInput & ImagePDFOptions): Promise<string[]>;
|
|
135
|
+
export interface PreviewOptions {
|
|
136
|
+
/**
|
|
137
|
+
* Height of the preview container. A number is treated as pixels;
|
|
138
|
+
* a string is used verbatim (e.g. "400px", "60vh", "30rem").
|
|
139
|
+
* Defaults to one full page height (`pageHeight` in mm).
|
|
140
|
+
*/
|
|
141
|
+
containerHeight?: number | string;
|
|
142
|
+
}
|
|
135
143
|
/**
|
|
136
144
|
* Render an HTML element as page images and inject them into a scrollable
|
|
137
145
|
* container. Each image is sized to match the page format dimensions.
|
|
138
146
|
*/
|
|
139
|
-
declare function previewImages(source: HTMLElement, container: HTMLElement, opts?: PageOptionsInput & ImagePDFOptions): Promise<void>;
|
|
147
|
+
declare function previewImages(source: HTMLElement, container: HTMLElement, opts?: PageOptionsInput & ImagePDFOptions & PreviewOptions): Promise<void>;
|
|
140
148
|
export { PAGE_SIZES, PAGE_MARGINS, generatePDF, generateImagePDF, generateImages, previewImages, };
|
package/dist/html-to-pdf.js
CHANGED
|
@@ -5990,20 +5990,22 @@ async function Mg(t, A = {}) {
|
|
|
5990
5990
|
}
|
|
5991
5991
|
}
|
|
5992
5992
|
async function Ng(t, A, e = {}) {
|
|
5993
|
-
const r = le(e), s = await Mg(t, e);
|
|
5993
|
+
const r = le(e), s = await Mg(t, e), n = e.containerHeight == null ? r.pageHeight + "mm" : typeof e.containerHeight == "number" ? e.containerHeight + "px" : e.containerHeight;
|
|
5994
5994
|
A.innerHTML = "", Object.assign(A.style, {
|
|
5995
5995
|
display: "flex",
|
|
5996
5996
|
flexDirection: "column",
|
|
5997
5997
|
direction: "ltr",
|
|
5998
5998
|
width: "fit-content",
|
|
5999
|
-
height:
|
|
6000
|
-
maxHeight:
|
|
6001
|
-
|
|
5999
|
+
height: n,
|
|
6000
|
+
maxHeight: n,
|
|
6001
|
+
// When the caller fixes the height, content may overflow even with a
|
|
6002
|
+
// single page, so always allow scrolling in that case.
|
|
6003
|
+
overflowY: e.containerHeight != null || s.length > 1 ? "auto" : "hidden",
|
|
6002
6004
|
background: "#e0e0e0"
|
|
6003
6005
|
});
|
|
6004
|
-
for (let
|
|
6005
|
-
const
|
|
6006
|
-
|
|
6006
|
+
for (let o = 0; o < s.length; o++) {
|
|
6007
|
+
const B = document.createElement("img");
|
|
6008
|
+
B.src = s[o], B.alt = `Page ${o + 1}`, Object.assign(B.style, {
|
|
6007
6009
|
width: r.pageWidth + "mm",
|
|
6008
6010
|
maxWidth: "100%",
|
|
6009
6011
|
height: "auto",
|
|
@@ -6011,7 +6013,7 @@ async function Ng(t, A, e = {}) {
|
|
|
6011
6013
|
border: "1px solid #bbb",
|
|
6012
6014
|
boxShadow: "0 2px 8px rgba(0,0,0,0.2)",
|
|
6013
6015
|
marginBottom: "16px"
|
|
6014
|
-
}),
|
|
6016
|
+
}), B.style.setProperty("display", "inline", "important"), A.appendChild(B);
|
|
6015
6017
|
}
|
|
6016
6018
|
}
|
|
6017
6019
|
async function Og(t, A, e = {}, r, s) {
|
package/package.json
CHANGED