element-to-pdf
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -10,2 +10,6 @@ import jspdf from 'jspdf'; | ||
declare type PDFPadding = [top: number, right: number, bottom: number, left: number]; | ||
declare type TransformPDFRes = { | ||
pdf: jspdf; | ||
doPrint: (newWindow?: boolean) => void; | ||
}; | ||
/** | ||
@@ -63,4 +67,3 @@ * @param {boolean} [inOnePdf = false] 多个元素是否生成在一个pdf中 | ||
startPage?: number; | ||
}): Promise<{ | ||
pdf: jspdf; | ||
}): Promise<TransformPDFRes & { | ||
pages: number; | ||
@@ -70,4 +73,4 @@ }>; | ||
elements: HTMLDivElement[]; | ||
}): Promise<jspdf[]>; | ||
}): Promise<TransformPDFRes[]>; | ||
} | ||
export default DomToPdf; |
@@ -63,3 +63,3 @@ var __assign = (this && this.__assign) || function () { | ||
* @LastEditors: wang0122xl@163.com | ||
* @LastEditTime: 2022-03-17 15:29:25 | ||
* @LastEditTime: 2022-03-18 13:04:11 | ||
* @Description: file content | ||
@@ -443,3 +443,15 @@ */ | ||
pdf: pdf, | ||
pages: currentPage | ||
pages: currentPage, | ||
doPrint: function (newWindow) { | ||
var _a; | ||
if (newWindow === void 0) { newWindow = true; } | ||
var iframe = document.createElement('iframe'); | ||
iframe.hidden = true; | ||
var url = URL.createObjectURL(pdf.output('blob')); | ||
iframe.src = url; | ||
var w = newWindow ? window.open() : window; | ||
w.document.body.appendChild(iframe); | ||
(_a = iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.print(); | ||
URL.revokeObjectURL(url); | ||
}, | ||
}]; | ||
@@ -457,3 +469,3 @@ } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, inOnePdf, elements, restProps, pdfs, defaultPdf, totalPages, i, ele, pdf, _b, resultPdf, pages; | ||
var _a, inOnePdf, elements, restProps, res, defaultPdf, totalPages, i, ele, pdf, _b, pages, item; | ||
return __generator(this, function (_c) { | ||
@@ -463,3 +475,3 @@ switch (_c.label) { | ||
_a = props.inOnePdf, inOnePdf = _a === void 0 ? true : _a, elements = props.elements, restProps = __rest(props, ["inOnePdf", "elements"]); | ||
pdfs = []; | ||
res = []; | ||
return [4 /*yield*/, this.createPdfIfNotExisted(restProps.size)]; | ||
@@ -482,5 +494,5 @@ case 1: | ||
case 4: | ||
_b = _c.sent(), resultPdf = _b.pdf, pages = _b.pages; | ||
_b = _c.sent(), pages = _b.pages, item = __rest(_b, ["pages"]); | ||
totalPages += pages; | ||
pdfs.push(resultPdf); | ||
res.push(item); | ||
_c.label = 5; | ||
@@ -490,3 +502,3 @@ case 5: | ||
return [3 /*break*/, 2]; | ||
case 6: return [2 /*return*/, inOnePdf ? [pdfs[0]] : pdfs]; | ||
case 6: return [2 /*return*/, inOnePdf ? [res[0]] : res]; | ||
} | ||
@@ -493,0 +505,0 @@ }); |
{ | ||
"name": "element-to-pdf", | ||
"private": false, | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"homepage": "https://wang0122xl.github.io/dom-to-pdf/", | ||
@@ -6,0 +6,0 @@ "main": "libs/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4050208
587