@sv-print/plugin-api-pdf 0.1.0 → 0.1.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/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # @sv-print/plugin-api-pdf
2
+
3
+ 给 sv-print 提供导出 PDF 的 API 插件。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install @sv-print/plugin-api-pdf
9
+ ```
10
+
11
+ ```js
12
+ import pluginApiPdf from "@sv-print/plugin-api-pdf";
13
+ const plugins = [pluginApiPdf({})];
14
+ ```
15
+
16
+ ## 示例
17
+
18
+ ```js
19
+ let hiprintTemplate = new hiprint.PrintTemplate(options);
20
+ // 其中 “text” 是一个元素的 “字段名(field)”
21
+ let printData = { text: "这是打印时显示的文本" };
22
+ const res = await hiprintTemplate.toPdf(printData, "pdf名称", {
23
+ isDownload: false, // 不自动下载
24
+ type: "blob", // 默认 blob 支持: blob、bloburl、pdfobjectnewwindow、dataurl --> jspdf.output(type)
25
+ onProgress: (cur, total) => {
26
+ const percent = Math.floor((cur / total) * 100);
27
+ console.log("toPdf 进度", percent);
28
+ },
29
+ });
30
+ console.log("toPdf", res);
31
+ ```
32
+
33
+ ## License
34
+
35
+ LGPL
36
+
37
+ ### 开源使用须知
38
+
39
+ 1.请自觉遵守 LGPL 协议,其他用途可联系作者;
40
+
41
+ 2.允许用于个人学习、毕业设计、教学案例、公益事业、商业使用;
42
+
43
+ 3.如果商用必须保留版权信息,请自觉遵守;
44
+
45
+ 4.禁止将本开源的代码和资源进行任何形式任何名义的出售,否则产生的一切任何后果责任由侵权者自负;
46
+
47
+ 5.商用请仔细审查代码和漏洞,不得用于任一国家许可范围之外的商业应用,产生的一切任何后果责任自负;
48
+
49
+ ```
50
+
51
+ ```
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var O=(x,a,t)=>new Promise((e,o)=>{var s=c=>{try{f(t.next(c))}catch(u){o(u)}},m=c=>{try{f(t.throw(c))}catch(u){o(u)}},f=c=>c.done?e(c.value):Promise.resolve(c.value).then(s,m);f((t=t.apply(x,a)).next())});const D=require("html-to-image"),R=require("jspdf");function k(x){if(x&&x.__esModule)return x;const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(x){for(const t in x)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(x,t);Object.defineProperty(a,t,e.get?e:{enumerable:!0,get:()=>x[t]})}}return a.default=x,Object.freeze(a)}const q=k(D);function v(x,a){var t=I();return v=function(e,o){e=e-164;var s=t[e];return s},v(x,a)}(function(x,a){for(var t=v,e=x();[];)try{var o=-parseInt(t(203))/1+parseInt(t(164))/2+-parseInt(t(195))/3*(parseInt(t(197))/4)+-parseInt(t(173))/5*(parseInt(t(206))/6)+parseInt(t(225))/7+parseInt(t(180))/8+parseInt(t(184))/9;if(o===a)break;e.push(e.shift())}catch(s){e.push(e.shift())}})(I,636902);function I(){var x=["gif","split","6461058iQvSab","add","createTempContainer","#fff",".hiprint-printPanel .hiprint-printPaper","Deferred","imageSmoothingEnabled","svg","jpg","log","find","baseURI","removeTempContainer","toPdf percent: ","http","indexOf","webp","printPanels","width","6373367SGTiUH","run","getContext","clear","1637740tZXHMw","pop","IMG","promise","output","height","toDataURL",".pdf","toPt","5jLGsWV","getTempContainer","length","total","blob","isDownload","type","1143592JsWoRv","src","floor","error","2640312ONcCNU","toLocaleLowerCase","cur","extend","svg2canvas","queue","onProgress","getOrient","hinnn","css","getHtml","159laaTrO","tagName","9176MRMMSC","save","image/jpeg","each","position:fixed","addImage","330341BdDuQb"];return I=function(){return x},I()}const A=function(x,a,t){return O(this,null,function*(){var e=v,o=this,s=globalThis.$[e(211)](),m=!![];let f=(l,P)=>{var d=e;const r=Math[d(182)](l/P*100);console[d(215)](d(186),l,d(176),P),console[d(215)](d(219),r+"%")};if(this.printPanels[e(175)]){var c=globalThis[e(192)].mm[e(172)](this[e(223)][0].width),u=globalThis.hinnn.mm[e(172)](this.printPanels[0][e(169)]),y=globalThis.$[e(187)]({filter:r=>{var n=e;return r[n(196)]!=n(166)||r[n(196)]=="IMG"&&([n(214),"jpeg","png",n(204),"bmp",n(222),n(213)].includes(r[n(181)][n(205)](".")[n(165)]().toLowerCase())||r[n(181)]!=r[n(217)]||r[n(181)][n(221)](n(220))>-1&&r[n(181)]!=r[n(217)]||r[n(181)].indexOf("base64")>-1)},backgroundColor:e(209)},t||{});const l=this.printPanels[0].paperType,P=l!=null&&l!=""&&l!="\u81EA\u5B9A\u4E49";var h=new R.jsPDF({orientation:this[e(191)](0)==1?"portrait":"landscape",unit:"pt",format:P?l[e(185)]():[c,u]}),g=yield this[e(194)](x,t);t&&t.isDownload!=null&&(m=t[e(178)]),t&&t.onProgress!=null&&(f=t[e(190)]),globalThis.$(g)[e(193)](e(224),"").css("height",""),this[e(208)]();var j=this[e(174)]();this[e(188)](g,y),j.html(g[0]);let d=j[e(216)](e(210))[e(175)];globalThis.$(g)[e(193)](e(201)),this.loadAllImages(g,function(){var r=e;try{j[r(216)](r(210))[r(200)](function(n,_){var p=r;globalThis[p(192)][p(189)][p(207)](function(M){q.toCanvas(_,y).then(function(i){var b=v,C=i[b(227)]("2d");C[b(212)]=![];var G=i[b(170)](b(199),y.quality||.92);h[b(202)](G,"JPEG",0,0,c,u),n<d-1&&h.addPage(),f(n+1,d),M()})}),n==d-1&&(globalThis[p(192)][p(189)][p(207)](function(M){var i=p;if(m)o[i(218)](),a[i(221)](i(171))>-1?h[i(198)](a):h[i(198)](a+i(171));else{o[i(218)]();let b=t[i(179)]||i(177),C=h[i(168)](b);s.resolve(C)}globalThis[i(192)][i(189)][i(228)]()}),globalThis[p(192)].queue[p(226)]())})}catch(n){console[r(183)]("toPdf \u5931\u8D25(\u53EF\u80FD\u60A8\u7684\u56FE\u7247\u8D44\u6E90\u65E0\u6CD5\u6B63\u5E38\u52A0\u8F7D): "),console.log(n)}})}return s[e(167)]()})};(function(x,a){for(var t=w,e=x();[];)try{var o=-parseInt(t(272))/1+-parseInt(t(281))/2+-parseInt(t(270))/3+parseInt(t(275))/4*(-parseInt(t(271))/5)+parseInt(t(282))/6+parseInt(t(280))/7*(parseInt(t(274))/8)+parseInt(t(283))/9;if(o===a)break;e.push(e.shift())}catch(s){e.push(e.shift())}})(T,175929);function w(x,a){var t=T();return w=function(e,o){e=e-270;var s=t[e];return s},w(x,a)}function T(){var x=["newPrintTemplate","defineProperty","toPdf","2421566IwQKqK","19148rRCHpQ","578370uwOEGF","428796RGwMwp","add toPdf Api","486303dHnszW","335yooKeM","13532GMAfxs","0.3.0","8zyLrNt","7692RBKxwC","add toPdf Api to PrintTemplate"];return T=function(){return x},T()}function H(x){var a=w;return{name:a(284),description:"add toPdf Api",hooks:[{hook:a(277),name:a(276),description:"add toPdf Api to PrintTemplate",priority:1,run:({template:t,options:e})=>{var o=a;Object[o(278)](t,o(279),{value:A,enumerable:![],writable:!![],configurable:!![]})}}],leastHiprintVersion:a(273)}}module.exports=H;
1
+ "use strict";var _=(x,n,t)=>new Promise((e,i)=>{var s=f=>{try{u(t.next(f))}catch(d){i(d)}},m=f=>{try{u(t.throw(f))}catch(d){i(d)}},u=f=>f.done?e(f.value):Promise.resolve(f.value).then(s,m);u((t=t.apply(x,n)).next())});const L=require("html-to-image"),M=require("jspdf");function S(x){if(x&&x.__esModule)return x;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(x){for(const t in x)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(x,t);Object.defineProperty(n,t,e.get?e:{enumerable:!0,get:()=>x[t]})}}return n.default=x,Object.freeze(n)}const A=S(L);(function(x,n){for(var t=P,e=x();[];)try{var i=-parseInt(t(219))/1*(-parseInt(t(220))/2)+-parseInt(t(243))/3+-parseInt(t(227))/4+parseInt(t(279))/5*(-parseInt(t(242))/6)+parseInt(t(239))/7*(parseInt(t(266))/8)+-parseInt(t(285))/9+parseInt(t(229))/10;if(i===n)break;e.push(e.shift())}catch(s){e.push(e.shift())}})(T,176031);function P(x,n){var t=T();return P=function(e,i){e=e-218;var s=t[e];return s},P(x,n)}const F=function(x,n,t){return _(this,null,function*(){var e=P,i=this,s=globalThis.$[e(244)](),m=!![];let u=(l,v)=>{var b=e;const a=Math.floor(l/v*100);console.log(b(218),l,b(264),v),console[b(263)]("toPdf percent: ",a+"%")};if(this[e(286)][e(231)]){var f=globalThis[e(269)].mm[e(253)](this[e(286)][0][e(270)]),d=globalThis[e(269)].mm[e(253)](this.printPanels[0][e(223)]),j=globalThis.$.extend({filter:a=>{var r=e;return a.tagName!=r(287)||a.tagName=="IMG"&&([r(222),r(280),r(258),"gif",r(241),r(256),r(230)][r(254)](a.src[r(281)](".")[r(248)]()[r(224)]())||a.src!=a[r(271)]||a.src.indexOf("http")>-1&&a[r(255)]!=a[r(271)]||a[r(255)][r(226)](r(247))>-1)},backgroundColor:e(228)},t||{});const l=this.printPanels[0][e(261)],v=l!=null&&l!=""&&l!=e(221);var h=new M.jsPDF({orientation:this[e(234)](0)==1?"portrait":e(233),unit:"pt",format:v?l[e(262)]():[f,d]}),g=yield this[e(273)](x,t);t&&t[e(277)]!=null&&(m=t.isDownload),t&&t.onProgress!=null&&(u=t.onProgress),globalThis.$(g)[e(265)](e(270),"")[e(265)](e(223),""),this[e(284)]();var C=this[e(267)]();this[e(283)](g,j),C[e(236)](g[0]);let b=C[e(276)](e(272)).length;globalThis.$(g)[e(265)](e(240)),this[e(235)](g,function(){var a=e;try{C[a(276)](".hiprint-printPanel .hiprint-printPaper")[a(237)](function(r,q){var p=a;globalThis[p(269)][p(249)][p(252)](function(O){var o=p;A.toCanvas(q,j)[o(278)](function(I){var c=o,D=I[c(238)]("2d");D[c(274)]=![];var k=I.toDataURL(c(251),j[c(245)]||.92);h[c(232)](k,c(259),0,0,f,d),r<b-1&&h.addPage(),u(r+1,b),O()})}),r==b-1&&(globalThis[p(269)].queue[p(252)](function(O){var o=p;if(m)i.removeTempContainer(),n[o(226)](o(257))>-1?h.save(n):h.save(n+o(257));else{i.removeTempContainer();let I=t[o(282)]||o(246),c=h[o(268)](I);s[o(250)](c)}globalThis[o(269)][o(249)][o(288)]()}),globalThis[p(269)][p(249)][p(225)]())})}catch(r){console[a(275)]("toPdf \u5931\u8D25(\u53EF\u80FD\u60A8\u7684\u56FE\u7247\u8D44\u6E90\u65E0\u6CD5\u6B63\u5E38\u52A0\u8F7D): "),console.log(r)}})}return s[e(260)]()})};function T(){var x=["126tSCgXA","525129zjKAbq","Deferred","quality","blob","base64","pop","queue","resolve","image/jpeg","add","toPt","includes","src","webp",".pdf","png","JPEG","promise","paperType","toLocaleLowerCase","log","total","css","8896yVUbSh","getTempContainer","output","hinnn","width","baseURI",".hiprint-printPanel .hiprint-printPaper","getHtml","imageSmoothingEnabled","error","find","isDownload","then","48295IFKXEc","jpeg","split","type","svg2canvas","createTempContainer","2474244rLXIHk","printPanels","IMG","clear","cur","28321uPIPma","10pcUdri","\u81EA\u5B9A\u4E49","jpg","height","toLowerCase","run","indexOf","616092WBemXG","#fff","5165430qCcCya","svg","length","addImage","landscape","getOrient","loadAllImages","html","each","getContext","2044bDOmYT","position:fixed","bmp"];return T=function(){return x},T()}(function(x,n){for(var t=y,e=x();[];)try{var i=-parseInt(t(437))/1*(-parseInt(t(438))/2)+parseInt(t(442))/3*(parseInt(t(432))/4)+-parseInt(t(439))/5*(-parseInt(t(436))/6)+-parseInt(t(447))/7+-parseInt(t(434))/8+parseInt(t(433))/9+-parseInt(t(446))/10*(-parseInt(t(441))/11);if(i===n)break;e.push(e.shift())}catch(s){e.push(e.shift())}})(w,620196);function y(x,n){var t=w();return y=function(e,i){e=e-432;var s=t[e];return s},y(x,n)}function z(x){var n=y;return{name:n(444),description:n(444),hooks:[{hook:n(443),name:n(440),description:n(440),priority:1,run:({template:t,options:e})=>{var i=n;Object[i(435)](t,i(445),{value:F,enumerable:![],writable:!![],configurable:!![]})}}],leastHiprintVersion:"0.3.0"}}function w(){var x=["7908523goyyri","17076opfbYs","987075HDZSFT","2837552bcFiTM","defineProperty","79998JfzewA","1zNsKFV","485556bmEBze","110MFLttU","add toPdf Api to PrintTemplate","3817cLRxoS","489aaaqip","newPrintTemplate","add toPdf Api","toPdf","21990nvmIEy"];return w=function(){return x},w()}module.exports=z;
package/dist/index.mjs CHANGED
@@ -1,129 +1,130 @@
1
- var O = (r, a, t) => new Promise((x, o) => {
2
- var s = (c) => {
1
+ var j = (r, n, x) => new Promise((e, i) => {
2
+ var s = (f) => {
3
3
  try {
4
- f(t.next(c));
5
- } catch (h) {
6
- o(h);
4
+ h(x.next(f));
5
+ } catch (u) {
6
+ i(u);
7
7
  }
8
- }, m = (c) => {
8
+ }, v = (f) => {
9
9
  try {
10
- f(t.throw(c));
11
- } catch (h) {
12
- o(h);
10
+ h(x.throw(f));
11
+ } catch (u) {
12
+ i(u);
13
13
  }
14
- }, f = (c) => c.done ? x(c.value) : Promise.resolve(c.value).then(s, m);
15
- f((t = t.apply(r, a)).next());
14
+ }, h = (f) => f.done ? e(f.value) : Promise.resolve(f.value).then(s, v);
15
+ h((x = x.apply(r, n)).next());
16
16
  });
17
- import * as A from "html-to-image";
18
- import { jsPDF as D } from "jspdf";
19
- function v(r, a) {
20
- var t = P();
21
- return v = function(x, o) {
22
- x = x - 164;
23
- var s = t[x];
24
- return s;
25
- }, v(r, a);
26
- }
27
- (function(r, a) {
28
- for (var t = v, x = r(); []; )
17
+ import * as F from "html-to-image";
18
+ import { jsPDF as E } from "jspdf";
19
+ (function(r, n) {
20
+ for (var x = P, e = r(); []; )
29
21
  try {
30
- var o = -parseInt(t(203)) / 1 + parseInt(t(164)) / 2 + -parseInt(t(195)) / 3 * (parseInt(t(197)) / 4) + -parseInt(t(173)) / 5 * (parseInt(t(206)) / 6) + parseInt(t(225)) / 7 + parseInt(t(180)) / 8 + parseInt(t(184)) / 9;
31
- if (o === a)
22
+ var i = -parseInt(x(219)) / 1 * (-parseInt(x(220)) / 2) + -parseInt(x(243)) / 3 + -parseInt(x(227)) / 4 + parseInt(x(279)) / 5 * (-parseInt(x(242)) / 6) + parseInt(x(239)) / 7 * (parseInt(x(266)) / 8) + -parseInt(x(285)) / 9 + parseInt(x(229)) / 10;
23
+ if (i === n)
32
24
  break;
33
- x.push(x.shift());
25
+ e.push(e.shift());
34
26
  } catch (s) {
35
- x.push(x.shift());
27
+ e.push(e.shift());
36
28
  }
37
- })(P, 636902);
38
- function P() {
39
- var r = ["gif", "split", "6461058iQvSab", "add", "createTempContainer", "#fff", ".hiprint-printPanel .hiprint-printPaper", "Deferred", "imageSmoothingEnabled", "svg", "jpg", "log", "find", "baseURI", "removeTempContainer", "toPdf percent: ", "http", "indexOf", "webp", "printPanels", "width", "6373367SGTiUH", "run", "getContext", "clear", "1637740tZXHMw", "pop", "IMG", "promise", "output", "height", "toDataURL", ".pdf", "toPt", "5jLGsWV", "getTempContainer", "length", "total", "blob", "isDownload", "type", "1143592JsWoRv", "src", "floor", "error", "2640312ONcCNU", "toLocaleLowerCase", "cur", "extend", "svg2canvas", "queue", "onProgress", "getOrient", "hinnn", "css", "getHtml", "159laaTrO", "tagName", "9176MRMMSC", "save", "image/jpeg", "each", "position:fixed", "addImage", "330341BdDuQb"];
40
- return P = function() {
41
- return r;
42
- }, P();
29
+ })(T, 176031);
30
+ function P(r, n) {
31
+ var x = T();
32
+ return P = function(e, i) {
33
+ e = e - 218;
34
+ var s = x[e];
35
+ return s;
36
+ }, P(r, n);
43
37
  }
44
- const H = function(r, a, t) {
45
- return O(this, null, function* () {
46
- var x = v, o = this, s = globalThis.$[x(211)](), m = !![];
47
- let f = (l, I) => {
48
- var d = x;
49
- const n = Math[d(182)](l / I * 100);
50
- console[d(215)](d(186), l, d(176), I), console[d(215)](d(219), n + "%");
38
+ const M = function(r, n, x) {
39
+ return j(this, null, function* () {
40
+ var e = P, i = this, s = globalThis.$[e(244)](), v = !![];
41
+ let h = (c, m) => {
42
+ var b = e;
43
+ const a = Math.floor(c / m * 100);
44
+ console.log(b(218), c, b(264), m), console[b(263)]("toPdf percent: ", a + "%");
51
45
  };
52
- if (this.printPanels[x(175)]) {
53
- var c = globalThis[x(192)].mm[x(172)](this[x(223)][0].width), h = globalThis.hinnn.mm[x(172)](this.printPanels[0][x(169)]), C = globalThis.$[x(187)]({ filter: (n) => {
54
- var e = x;
55
- return n[e(196)] != e(166) || n[e(196)] == "IMG" && ([e(214), "jpeg", "png", e(204), "bmp", e(222), e(213)].includes(n[e(181)][e(205)](".")[e(165)]().toLowerCase()) || n[e(181)] != n[e(217)] || n[e(181)][e(221)](e(220)) > -1 && n[e(181)] != n[e(217)] || n[e(181)].indexOf("base64") > -1);
56
- }, backgroundColor: x(209) }, t || {});
57
- const l = this.printPanels[0].paperType, I = l != null && l != "" && l != "\u81EA\u5B9A\u4E49";
58
- var u = new D({ orientation: this[x(191)](0) == 1 ? "portrait" : "landscape", unit: "pt", format: I ? l[x(185)]() : [c, h] }), g = yield this[x(194)](r, t);
59
- t && t.isDownload != null && (m = t[x(178)]), t && t.onProgress != null && (f = t[x(190)]), globalThis.$(g)[x(193)](x(224), "").css("height", ""), this[x(208)]();
60
- var y = this[x(174)]();
61
- this[x(188)](g, C), y.html(g[0]);
62
- let d = y[x(216)](x(210))[x(175)];
63
- globalThis.$(g)[x(193)](x(201)), this.loadAllImages(g, function() {
64
- var n = x;
46
+ if (this[e(286)][e(231)]) {
47
+ var f = globalThis[e(269)].mm[e(253)](this[e(286)][0][e(270)]), u = globalThis[e(269)].mm[e(253)](this.printPanels[0][e(223)]), C = globalThis.$.extend({ filter: (a) => {
48
+ var t = e;
49
+ return a.tagName != t(287) || a.tagName == "IMG" && ([t(222), t(280), t(258), "gif", t(241), t(256), t(230)][t(254)](a.src[t(281)](".")[t(248)]()[t(224)]()) || a.src != a[t(271)] || a.src.indexOf("http") > -1 && a[t(255)] != a[t(271)] || a[t(255)][t(226)](t(247)) > -1);
50
+ }, backgroundColor: e(228) }, x || {});
51
+ const c = this.printPanels[0][e(261)], m = c != null && c != "" && c != e(221);
52
+ var d = new E({ orientation: this[e(234)](0) == 1 ? "portrait" : e(233), unit: "pt", format: m ? c[e(262)]() : [f, u] }), g = yield this[e(273)](r, x);
53
+ x && x[e(277)] != null && (v = x.isDownload), x && x.onProgress != null && (h = x.onProgress), globalThis.$(g)[e(265)](e(270), "")[e(265)](e(223), ""), this[e(284)]();
54
+ var D = this[e(267)]();
55
+ this[e(283)](g, C), D[e(236)](g[0]);
56
+ let b = D[e(276)](e(272)).length;
57
+ globalThis.$(g)[e(265)](e(240)), this[e(235)](g, function() {
58
+ var a = e;
65
59
  try {
66
- y[n(216)](n(210))[n(200)](function(e, R) {
67
- var p = n;
68
- globalThis[p(192)][p(189)][p(207)](function(G) {
69
- A.toCanvas(R, C).then(function(i) {
70
- var b = v, M = i[b(227)]("2d");
71
- M[b(212)] = ![];
72
- var j = i[b(170)](b(199), C.quality || 0.92);
73
- u[b(202)](j, "JPEG", 0, 0, c, h), e < d - 1 && u.addPage(), f(e + 1, d), G();
60
+ D[a(276)](".hiprint-printPanel .hiprint-printPaper")[a(237)](function(t, k) {
61
+ var p = a;
62
+ globalThis[p(269)][p(249)][p(252)](function(L) {
63
+ var o = p;
64
+ F.toCanvas(k, C)[o(278)](function(I) {
65
+ var l = o, q = I[l(238)]("2d");
66
+ q[l(274)] = ![];
67
+ var A = I.toDataURL(l(251), C[l(245)] || 0.92);
68
+ d[l(232)](A, l(259), 0, 0, f, u), t < b - 1 && d.addPage(), h(t + 1, b), L();
74
69
  });
75
- }), e == d - 1 && (globalThis[p(192)][p(189)][p(207)](function(G) {
76
- var i = p;
77
- if (m)
78
- o[i(218)](), a[i(221)](i(171)) > -1 ? u[i(198)](a) : u[i(198)](a + i(171));
70
+ }), t == b - 1 && (globalThis[p(269)].queue[p(252)](function(L) {
71
+ var o = p;
72
+ if (v)
73
+ i.removeTempContainer(), n[o(226)](o(257)) > -1 ? d.save(n) : d.save(n + o(257));
79
74
  else {
80
- o[i(218)]();
81
- let b = t[i(179)] || i(177), M = u[i(168)](b);
82
- s.resolve(M);
75
+ i.removeTempContainer();
76
+ let I = x[o(282)] || o(246), l = d[o(268)](I);
77
+ s[o(250)](l);
83
78
  }
84
- globalThis[i(192)][i(189)][i(228)]();
85
- }), globalThis[p(192)].queue[p(226)]());
79
+ globalThis[o(269)][o(249)][o(288)]();
80
+ }), globalThis[p(269)][p(249)][p(225)]());
86
81
  });
87
- } catch (e) {
88
- console[n(183)]("toPdf \u5931\u8D25(\u53EF\u80FD\u60A8\u7684\u56FE\u7247\u8D44\u6E90\u65E0\u6CD5\u6B63\u5E38\u52A0\u8F7D): "), console.log(e);
82
+ } catch (t) {
83
+ console[a(275)]("toPdf \u5931\u8D25(\u53EF\u80FD\u60A8\u7684\u56FE\u7247\u8D44\u6E90\u65E0\u6CD5\u6B63\u5E38\u52A0\u8F7D): "), console.log(t);
89
84
  }
90
85
  });
91
86
  }
92
- return s[x(167)]();
87
+ return s[e(260)]();
93
88
  });
94
89
  };
95
- (function(r, a) {
96
- for (var t = w, x = r(); []; )
90
+ function T() {
91
+ var r = ["126tSCgXA", "525129zjKAbq", "Deferred", "quality", "blob", "base64", "pop", "queue", "resolve", "image/jpeg", "add", "toPt", "includes", "src", "webp", ".pdf", "png", "JPEG", "promise", "paperType", "toLocaleLowerCase", "log", "total", "css", "8896yVUbSh", "getTempContainer", "output", "hinnn", "width", "baseURI", ".hiprint-printPanel .hiprint-printPaper", "getHtml", "imageSmoothingEnabled", "error", "find", "isDownload", "then", "48295IFKXEc", "jpeg", "split", "type", "svg2canvas", "createTempContainer", "2474244rLXIHk", "printPanels", "IMG", "clear", "cur", "28321uPIPma", "10pcUdri", "\u81EA\u5B9A\u4E49", "jpg", "height", "toLowerCase", "run", "indexOf", "616092WBemXG", "#fff", "5165430qCcCya", "svg", "length", "addImage", "landscape", "getOrient", "loadAllImages", "html", "each", "getContext", "2044bDOmYT", "position:fixed", "bmp"];
92
+ return T = function() {
93
+ return r;
94
+ }, T();
95
+ }
96
+ (function(r, n) {
97
+ for (var x = y, e = r(); []; )
97
98
  try {
98
- var o = -parseInt(t(272)) / 1 + -parseInt(t(281)) / 2 + -parseInt(t(270)) / 3 + parseInt(t(275)) / 4 * (-parseInt(t(271)) / 5) + parseInt(t(282)) / 6 + parseInt(t(280)) / 7 * (parseInt(t(274)) / 8) + parseInt(t(283)) / 9;
99
- if (o === a)
99
+ var i = -parseInt(x(437)) / 1 * (-parseInt(x(438)) / 2) + parseInt(x(442)) / 3 * (parseInt(x(432)) / 4) + -parseInt(x(439)) / 5 * (-parseInt(x(436)) / 6) + -parseInt(x(447)) / 7 + -parseInt(x(434)) / 8 + parseInt(x(433)) / 9 + -parseInt(x(446)) / 10 * (-parseInt(x(441)) / 11);
100
+ if (i === n)
100
101
  break;
101
- x.push(x.shift());
102
+ e.push(e.shift());
102
103
  } catch (s) {
103
- x.push(x.shift());
104
+ e.push(e.shift());
104
105
  }
105
- })(T, 175929);
106
- function w(r, a) {
107
- var t = T();
108
- return w = function(x, o) {
109
- x = x - 270;
110
- var s = t[x];
106
+ })(w, 620196);
107
+ function y(r, n) {
108
+ var x = w();
109
+ return y = function(e, i) {
110
+ e = e - 432;
111
+ var s = x[e];
111
112
  return s;
112
- }, w(r, a);
113
+ }, y(r, n);
113
114
  }
114
- function T() {
115
- var r = ["newPrintTemplate", "defineProperty", "toPdf", "2421566IwQKqK", "19148rRCHpQ", "578370uwOEGF", "428796RGwMwp", "add toPdf Api", "486303dHnszW", "335yooKeM", "13532GMAfxs", "0.3.0", "8zyLrNt", "7692RBKxwC", "add toPdf Api to PrintTemplate"];
116
- return T = function() {
117
- return r;
118
- }, T();
115
+ function U(r) {
116
+ var n = y;
117
+ return { name: n(444), description: n(444), hooks: [{ hook: n(443), name: n(440), description: n(440), priority: 1, run: ({ template: x, options: e }) => {
118
+ var i = n;
119
+ Object[i(435)](x, i(445), { value: M, enumerable: ![], writable: !![], configurable: !![] });
120
+ } }], leastHiprintVersion: "0.3.0" };
119
121
  }
120
- function q(r) {
121
- var a = w;
122
- return { name: a(284), description: "add toPdf Api", hooks: [{ hook: a(277), name: a(276), description: "add toPdf Api to PrintTemplate", priority: 1, run: ({ template: t, options: x }) => {
123
- var o = a;
124
- Object[o(278)](t, o(279), { value: H, enumerable: ![], writable: !![], configurable: !![] });
125
- } }], leastHiprintVersion: a(273) };
122
+ function w() {
123
+ var r = ["7908523goyyri", "17076opfbYs", "987075HDZSFT", "2837552bcFiTM", "defineProperty", "79998JfzewA", "1zNsKFV", "485556bmEBze", "110MFLttU", "add toPdf Api to PrintTemplate", "3817cLRxoS", "489aaaqip", "newPrintTemplate", "add toPdf Api", "toPdf", "21990nvmIEy"];
124
+ return w = function() {
125
+ return r;
126
+ }, w();
126
127
  }
127
128
  export {
128
- q as default
129
+ U as default
129
130
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(c,b){typeof exports=="object"&&typeof module!="undefined"?module.exports=b(require("html-to-image"),require("jspdf")):typeof define=="function"&&define.amd?define(["html-to-image","jspdf"],b):(c=typeof globalThis!="undefined"?globalThis:c||self,c.pluginApiPdf=b(c.htmlToImage,c.jspdf))})(this,function(c,b){"use strict";var k=(c,b,m)=>new Promise((y,l)=>{var v=o=>{try{f(m.next(o))}catch(P){l(P)}},j=o=>{try{f(m.throw(o))}catch(P){l(P)}},f=o=>o.done?y(o.value):Promise.resolve(o.value).then(v,j);f((m=m.apply(c,b)).next())});function m(n){if(n&&n.__esModule)return n;const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(a,t,e.get?e:{enumerable:!0,get:()=>n[t]})}}return a.default=n,Object.freeze(a)}const y=m(c);function l(n,a){var t=v();return l=function(e,s){e=e-164;var u=t[e];return u},l(n,a)}(function(n,a){for(var t=l,e=n();[];)try{var s=-parseInt(t(203))/1+parseInt(t(164))/2+-parseInt(t(195))/3*(parseInt(t(197))/4)+-parseInt(t(173))/5*(parseInt(t(206))/6)+parseInt(t(225))/7+parseInt(t(180))/8+parseInt(t(184))/9;if(s===a)break;e.push(e.shift())}catch(u){e.push(e.shift())}})(v,636902);function v(){var n=["gif","split","6461058iQvSab","add","createTempContainer","#fff",".hiprint-printPanel .hiprint-printPaper","Deferred","imageSmoothingEnabled","svg","jpg","log","find","baseURI","removeTempContainer","toPdf percent: ","http","indexOf","webp","printPanels","width","6373367SGTiUH","run","getContext","clear","1637740tZXHMw","pop","IMG","promise","output","height","toDataURL",".pdf","toPt","5jLGsWV","getTempContainer","length","total","blob","isDownload","type","1143592JsWoRv","src","floor","error","2640312ONcCNU","toLocaleLowerCase","cur","extend","svg2canvas","queue","onProgress","getOrient","hinnn","css","getHtml","159laaTrO","tagName","9176MRMMSC","save","image/jpeg","each","position:fixed","addImage","330341BdDuQb"];return v=function(){return n},v()}const j=function(n,a,t){return k(this,null,function*(){var e=l,s=this,u=globalThis.$[e(211)](),G=!![];let _=(h,w)=>{var d=e;const r=Math[d(182)](h/w*100);console[d(215)](d(186),h,d(176),w),console[d(215)](d(219),r+"%")};if(this.printPanels[e(175)]){var A=globalThis[e(192)].mm[e(172)](this[e(223)][0].width),D=globalThis.hinnn.mm[e(172)](this.printPanels[0][e(169)]),C=globalThis.$[e(187)]({filter:r=>{var x=e;return r[x(196)]!=x(166)||r[x(196)]=="IMG"&&([x(214),"jpeg","png",x(204),"bmp",x(222),x(213)].includes(r[x(181)][x(205)](".")[x(165)]().toLowerCase())||r[x(181)]!=r[x(217)]||r[x(181)][x(221)](x(220))>-1&&r[x(181)]!=r[x(217)]||r[x(181)].indexOf("base64")>-1)},backgroundColor:e(209)},t||{});const h=this.printPanels[0].paperType,w=h!=null&&h!=""&&h!="\u81EA\u5B9A\u4E49";var I=new b.jsPDF({orientation:this[e(191)](0)==1?"portrait":"landscape",unit:"pt",format:w?h[e(185)]():[A,D]}),T=yield this[e(194)](n,t);t&&t.isDownload!=null&&(G=t[e(178)]),t&&t.onProgress!=null&&(_=t[e(190)]),globalThis.$(T)[e(193)](e(224),"").css("height",""),this[e(208)]();var M=this[e(174)]();this[e(188)](T,C),M.html(T[0]);let d=M[e(216)](e(210))[e(175)];globalThis.$(T)[e(193)](e(201)),this.loadAllImages(T,function(){var r=e;try{M[r(216)](r(210))[r(200)](function(x,q){var p=r;globalThis[p(192)][p(189)][p(207)](function(R){y.toCanvas(q,C).then(function(i){var g=l,O=i[g(227)]("2d");O[g(212)]=![];var H=i[g(170)](g(199),C.quality||.92);I[g(202)](H,"JPEG",0,0,A,D),x<d-1&&I.addPage(),_(x+1,d),R()})}),x==d-1&&(globalThis[p(192)][p(189)][p(207)](function(R){var i=p;if(G)s[i(218)](),a[i(221)](i(171))>-1?I[i(198)](a):I[i(198)](a+i(171));else{s[i(218)]();let g=t[i(179)]||i(177),O=I[i(168)](g);u.resolve(O)}globalThis[i(192)][i(189)][i(228)]()}),globalThis[p(192)].queue[p(226)]())})}catch(x){console[r(183)]("toPdf \u5931\u8D25(\u53EF\u80FD\u60A8\u7684\u56FE\u7247\u8D44\u6E90\u65E0\u6CD5\u6B63\u5E38\u52A0\u8F7D): "),console.log(x)}})}return u[e(167)]()})};(function(n,a){for(var t=f,e=n();[];)try{var s=-parseInt(t(272))/1+-parseInt(t(281))/2+-parseInt(t(270))/3+parseInt(t(275))/4*(-parseInt(t(271))/5)+parseInt(t(282))/6+parseInt(t(280))/7*(parseInt(t(274))/8)+parseInt(t(283))/9;if(s===a)break;e.push(e.shift())}catch(u){e.push(e.shift())}})(o,175929);function f(n,a){var t=o();return f=function(e,s){e=e-270;var u=t[e];return u},f(n,a)}function o(){var n=["newPrintTemplate","defineProperty","toPdf","2421566IwQKqK","19148rRCHpQ","578370uwOEGF","428796RGwMwp","add toPdf Api","486303dHnszW","335yooKeM","13532GMAfxs","0.3.0","8zyLrNt","7692RBKxwC","add toPdf Api to PrintTemplate"];return o=function(){return n},o()}function P(n){var a=f;return{name:a(284),description:"add toPdf Api",hooks:[{hook:a(277),name:a(276),description:"add toPdf Api to PrintTemplate",priority:1,run:({template:t,options:e})=>{var s=a;Object[s(278)](t,s(279),{value:j,enumerable:![],writable:!![],configurable:!![]})}}],leastHiprintVersion:a(273)}}return P});
1
+ (function(f,d){typeof exports=="object"&&typeof module!="undefined"?module.exports=d(require("html-to-image"),require("jspdf")):typeof define=="function"&&define.amd?define(["html-to-image","jspdf"],d):(f=typeof globalThis!="undefined"?globalThis:f||self,f.pluginApiPdf=d(f.htmlToImage,f.jspdf))})(this,function(f,d){"use strict";var M=(f,d,v)=>new Promise((w,h)=>{var C=p=>{try{c(v.next(p))}catch(l){h(l)}},I=p=>{try{c(v.throw(p))}catch(l){h(l)}},c=p=>p.done?w(p.value):Promise.resolve(p.value).then(C,I);c((v=v.apply(f,d)).next())});function v(n){if(n&&n.__esModule)return n;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(r,t,e.get?e:{enumerable:!0,get:()=>n[t]})}}return r.default=n,Object.freeze(r)}const w=v(f);(function(n,r){for(var t=h,e=n();[];)try{var o=-parseInt(t(219))/1*(-parseInt(t(220))/2)+-parseInt(t(243))/3+-parseInt(t(227))/4+parseInt(t(279))/5*(-parseInt(t(242))/6)+parseInt(t(239))/7*(parseInt(t(266))/8)+-parseInt(t(285))/9+parseInt(t(229))/10;if(o===r)break;e.push(e.shift())}catch(u){e.push(e.shift())}})(I,176031);function h(n,r){var t=I();return h=function(e,o){e=e-218;var u=t[e];return u},h(n,r)}const C=function(n,r,t){return M(this,null,function*(){var e=h,o=this,u=globalThis.$[e(244)](),q=!![];let D=(g,y)=>{var m=e;const i=Math.floor(g/y*100);console.log(m(218),g,m(264),y),console[m(263)]("toPdf percent: ",i+"%")};if(this[e(286)][e(231)]){var k=globalThis[e(269)].mm[e(253)](this[e(286)][0][e(270)]),A=globalThis[e(269)].mm[e(253)](this.printPanels[0][e(223)]),O=globalThis.$.extend({filter:i=>{var x=e;return i.tagName!=x(287)||i.tagName=="IMG"&&([x(222),x(280),x(258),"gif",x(241),x(256),x(230)][x(254)](i.src[x(281)](".")[x(248)]()[x(224)]())||i.src!=i[x(271)]||i.src.indexOf("http")>-1&&i[x(255)]!=i[x(271)]||i[x(255)][x(226)](x(247))>-1)},backgroundColor:e(228)},t||{});const g=this.printPanels[0][e(261)],y=g!=null&&g!=""&&g!=e(221);var P=new d.jsPDF({orientation:this[e(234)](0)==1?"portrait":e(233),unit:"pt",format:y?g[e(262)]():[k,A]}),T=yield this[e(273)](n,t);t&&t[e(277)]!=null&&(q=t.isDownload),t&&t.onProgress!=null&&(D=t.onProgress),globalThis.$(T)[e(265)](e(270),"")[e(265)](e(223),""),this[e(284)]();var _=this[e(267)]();this[e(283)](T,O),_[e(236)](T[0]);let m=_[e(276)](e(272)).length;globalThis.$(T)[e(265)](e(240)),this[e(235)](T,function(){var i=e;try{_[i(276)](".hiprint-printPanel .hiprint-printPaper")[i(237)](function(x,S){var s=i;globalThis[s(269)][s(249)][s(252)](function(L){var a=s;w.toCanvas(S,O)[a(278)](function(j){var b=a,F=j[b(238)]("2d");F[b(274)]=![];var z=j.toDataURL(b(251),O[b(245)]||.92);P[b(232)](z,b(259),0,0,k,A),x<m-1&&P.addPage(),D(x+1,m),L()})}),x==m-1&&(globalThis[s(269)].queue[s(252)](function(L){var a=s;if(q)o.removeTempContainer(),r[a(226)](a(257))>-1?P.save(r):P.save(r+a(257));else{o.removeTempContainer();let j=t[a(282)]||a(246),b=P[a(268)](j);u[a(250)](b)}globalThis[a(269)][a(249)][a(288)]()}),globalThis[s(269)][s(249)][s(225)]())})}catch(x){console[i(275)]("toPdf \u5931\u8D25(\u53EF\u80FD\u60A8\u7684\u56FE\u7247\u8D44\u6E90\u65E0\u6CD5\u6B63\u5E38\u52A0\u8F7D): "),console.log(x)}})}return u[e(260)]()})};function I(){var n=["126tSCgXA","525129zjKAbq","Deferred","quality","blob","base64","pop","queue","resolve","image/jpeg","add","toPt","includes","src","webp",".pdf","png","JPEG","promise","paperType","toLocaleLowerCase","log","total","css","8896yVUbSh","getTempContainer","output","hinnn","width","baseURI",".hiprint-printPanel .hiprint-printPaper","getHtml","imageSmoothingEnabled","error","find","isDownload","then","48295IFKXEc","jpeg","split","type","svg2canvas","createTempContainer","2474244rLXIHk","printPanels","IMG","clear","cur","28321uPIPma","10pcUdri","\u81EA\u5B9A\u4E49","jpg","height","toLowerCase","run","indexOf","616092WBemXG","#fff","5165430qCcCya","svg","length","addImage","landscape","getOrient","loadAllImages","html","each","getContext","2044bDOmYT","position:fixed","bmp"];return I=function(){return n},I()}(function(n,r){for(var t=c,e=n();[];)try{var o=-parseInt(t(437))/1*(-parseInt(t(438))/2)+parseInt(t(442))/3*(parseInt(t(432))/4)+-parseInt(t(439))/5*(-parseInt(t(436))/6)+-parseInt(t(447))/7+-parseInt(t(434))/8+parseInt(t(433))/9+-parseInt(t(446))/10*(-parseInt(t(441))/11);if(o===r)break;e.push(e.shift())}catch(u){e.push(e.shift())}})(l,620196);function c(n,r){var t=l();return c=function(e,o){e=e-432;var u=t[e];return u},c(n,r)}function p(n){var r=c;return{name:r(444),description:r(444),hooks:[{hook:r(443),name:r(440),description:r(440),priority:1,run:({template:t,options:e})=>{var o=r;Object[o(435)](t,o(445),{value:C,enumerable:![],writable:!![],configurable:!![]})}}],leastHiprintVersion:"0.3.0"}}function l(){var n=["7908523goyyri","17076opfbYs","987075HDZSFT","2837552bcFiTM","defineProperty","79998JfzewA","1zNsKFV","485556bmEBze","110MFLttU","add toPdf Api to PrintTemplate","3817cLRxoS","489aaaqip","newPrintTemplate","add toPdf Api","toPdf","21990nvmIEy"];return l=function(){return n},l()}return p});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sv-print/plugin-api-pdf",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "add pdf api to print template",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",