diff --git a/assets/index.b2b22e39.js b/assets/index.b2b22e39.js new file mode 100644 index 0000000..526ed87 --- /dev/null +++ b/assets/index.b2b22e39.js @@ -0,0 +1 @@ +import{F as w,P as h}from"./vendor.b3b4cbce.js";import{p}from"./vendor.pdfjs.df470f9c.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const t of n.addedNodes)t.tagName==="LINK"&&t.rel==="modulepreload"&&o(t)}).observe(document,{childList:!0,subtree:!0});function a(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerpolicy&&(n.referrerPolicy=r.referrerpolicy),r.crossorigin==="use-credentials"?n.credentials="include":r.crossorigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function o(r){if(r.ep)return;r.ep=!0;const n=a(r);fetch(r.href,n)}})();function g(d){switch(d){case"dhl-privat":return I;case"dhl-privat-international":return f;case"dhl-privat-international-native":return m;case"dhl-retoure":return u;case"dp-briefmarke":return b;case"dp-briefmarke-short":return v;case"dp-briefmarke-adresse":return P;case"hermes-privat-v102":return T;case"adidas":return y;case"amazon-dhl":return k;case"mediamarkt-saturn":return L;case"nike-dhl":return S;case"dhl-nl-4-4":return z;case"dhl-nl-4-5":return M;case"dhl-nl-5-4":return B;case"dhl-nl-5-5":return D;default:console.error("Unknown label type.")}}const I={file:{type:"pdf",page:1,rotation:90},width:1642,crop(d,e,a){e.drawImage(a,1964,106,1124,94,0,0,890,74),e.drawImage(a,1964,210,785,625,0,95,580,465);let o=296;e.drawImage(a,2763,215,o,o,594,90,o,o),e.rotate(-Math.PI/2),e.drawImage(a,3075,244,20,194,-395,645,-20,194),e.rotate(Math.PI/2),e.drawImage(a,2802,679,234,154,666,465,152,100),e.drawImage(a,1964,933,1124,152,0,576,890,120),e.beginPath(),e.moveTo(910,0),e.lineTo(910,d.height),e.stroke();let r=710,n=320;e.drawImage(a,2181,1526,r,n,930,20,r,n),e.drawImage(a,2181,1940,r,n,930,376,r,n)}},f={file:{type:"pdf",page:1,rotation:90},width:2232,crop(d,e,a){e.drawImage(a,1964,106,1124,94,0,0,890,74),e.drawImage(a,1964,210,785,625,0,95,580,465);let o=296;e.drawImage(a,2763,215,o,o,594,90,o,o),e.rotate(-Math.PI/2),e.drawImage(a,3075,244,20,194,-395,645,-20,194),e.rotate(Math.PI/2),e.drawImage(a,2768,743,300,60,590,495,300,60),e.drawImage(a,1964,933,1124,152,0,576,890,120),e.beginPath(),e.moveTo(910,0),e.lineTo(910,d.height),e.stroke(),e.rotate(-Math.PI/2),e.drawImage(a,1964,854,1124,70,-696,920,696,43),e.drawImage(a,1964,1197,1124,122,-696,986,696,76),e.rotate(Math.PI/2),e.drawImage(a,2846,530,130,202,930,10,130,202),e.beginPath(),e.moveTo(920,230),e.lineTo(1070,230),e.stroke(),e.beginPath(),e.moveTo(970,240),e.lineTo(970,d.height),e.stroke(),e.beginPath(),e.moveTo(1080,0),e.lineTo(1080,d.height),e.stroke();let r=1124,n=280;e.drawImage(a,1964,1422,r,70,1100,4,r,70),e.drawImage(a,1964,1634,r,n,1100,100,r,n),e.drawImage(a,1964,2e3,160,n-20,1100,416,160,n-20),e.drawImage(a,1964,2048+260,160,20,1100,416+260,160,20),e.drawImage(a,1964+160,2048,r-160,n,1100+160,416,r-160,n)}},m={file:{type:"pdf",page:1,rotation:90},width:1878,crop(d,e,a){e.drawImage(a,1964,108,1124,92,0,12,890,73),e.drawImage(a,1964,210,785,625,0,90,580,465);let o=296;e.drawImage(a,2763,215,o,o,594,95,o,o),e.rotate(-Math.PI/2),e.drawImage(a,3075,244,20,194,-395,645,-20,194),e.rotate(Math.PI/2),e.drawImage(a,2768,743,300,60,590,495,300,60),e.drawImage(a,1964,933,1124,152,0,565,890,120),e.beginPath(),e.moveTo(910,12),e.lineTo(910,d.height-12),e.stroke();let r=940,n=270;e.drawImage(a,1964,1422,r,70,930,15,r,70),e.drawImage(a,2066,1644,r,n,936,110,r,n),e.drawImage(a,2066,2058,r,n,936,416,r,n)}},u={file:{type:"pdf",page:1,rotation:90},width:1642,crop(d,e,a){e.drawImage(a,2020,85,500,70,0,12,450,63),e.drawImage(a,2780,85,250,70,425,12,225,63),e.drawImage(a,2020,162,720,200,0,90,648,180),e.drawImage(a,2020,435,720,270,0,280,648,243),e.beginPath(),e.moveTo(0,580),e.lineTo(650,580),e.stroke(),e.drawImage(a,2020,745,720,110,0,590,648,99),e.beginPath(),e.moveTo(665,12),e.lineTo(665,d.height-12),e.stroke();let o=950,r=240;e.drawImage(a,2030,1230,o,120,686,15,o,120),e.drawImage(a,2030,1460,o,r,686,170,o,r),e.drawImage(a,2030,1810,o,r,686,445,o,r)}},b={file:{type:"pdf",page:1,rotation:90},scale:4.1666,width:402,crop(d,e,a){e.drawImage(a,17,11,402,696,0,0,402,696)}},v={file:{type:"pdf",page:1,rotation:90},scale:4.1666,width:283,crop(d,e,a){e.drawImage(a,136,11,283,696,0,0,283,696)}},P={file:{type:"pdf",page:1,rotation:90},scale:4.1666,width:874,crop(d,e,a){e.drawImage(a,64,18,874,696,0,0,874,696)}},T={file:{type:"pdf",page:1,rotation:0},width:1701,crop(d,e,a){e.drawImage(a,185,180,915,45,20,20,915,45),e.drawImage(a,200,1115,770,350,20,80,770,350),e.drawImage(a,1625,165,485,80,40,460,364,60),e.drawImage(a,1100,280,350,95,130,540,313,85),e.rotate(Math.PI/2),e.drawImage(a,2140,350,70,1020,650,-20,35,-510),e.rotate(-Math.PI/2),e.drawImage(a,1100,425,580,260,810,100,493,221),e.drawImage(a,780,870,250,220,560,370,225,198),e.drawImage(a,1100,865,580,260,810,370,493,221),e.drawImage(a,1100,1245,580,40,810,630,493,34),e.drawImage(a,1850,1325,230,140,645,600,138,84),e.drawImage(a,1640,1330,110,140,560,600,66,84),e.drawImage(a,210,370,370,640,1320,28,370,640),e.lineWidth=4,e.beginPath(),e.moveTo(0,2),e.lineTo(this.width,2),e.stroke(),e.beginPath(),e.moveTo(0,d.height-2),e.lineTo(this.width,d.height-2),e.stroke(),e.beginPath(),e.moveTo(2,4),e.lineTo(2,d.height-4),e.stroke(),e.beginPath(),e.moveTo(this.width-2,4),e.lineTo(this.width-2,d.height-4),e.stroke()}},y={file:{type:"pdf",page:1,rotation:0},width:1346,crop(d,e,a){e.drawImage(a,354,63,824,54,0,12,648,42),e.beginPath(),e.moveTo(0,65),e.lineTo(650,65),e.stroke(),e.drawImage(a,86,128,648,190,0,90,648,190),e.drawImage(a,86,319,527,262,0,280,527,262),e.drawImage(a,785,319,121,262,527,280,121,262),e.beginPath(),e.moveTo(0,580),e.lineTo(650,580),e.stroke(),e.drawImage(a,96,680,1010,140,0,590,648,90),e.beginPath(),e.moveTo(665,12),e.lineTo(665,d.height-12),e.stroke();let o=610,r=240;e.drawImage(a,1390,616,o,80,715,15,o,80),e.drawImage(a,1400,816,420,54,735,100,311,40),e.drawImage(a,170,952,o,r,715,180,o,r),e.drawImage(a,170,1326,o,r,715,445,o,r)}},k={file:{type:"gif"},width:1346,crop(d,e,a){e.rotate(Math.PI/2),e.drawImage(a,15,0,80,370,0,-20,80,-370),e.drawImage(a,0,605,580,460,80,0,580,-460),e.beginPath(),e.moveTo(12,-470),e.lineTo(d.height-12,-470),e.stroke(),e.drawImage(a,730,150,160,800,15,-520,160,-800);let o=220,r=600;e.drawImage(a,1110,280,o,r,220,-620,o,-r),e.drawImage(a,1540,290,o,r,465,-660,o,-r)}},L={file:{type:"pdf",page:3,rotation:90},width:1642,crop(d,e,a){e.drawImage(a,2188,243,1010,60,0,12,900,53),e.beginPath(),e.moveTo(0,75),e.lineTo(900,75),e.stroke(),e.drawImage(a,2197,361,150,376,0,100,150,376),e.drawImage(a,2419,361,750,376,150,100,750,376),e.beginPath(),e.moveTo(0,520),e.lineTo(900,520),e.stroke(),e.drawImage(a,2180,875,1010,165,0,530,900,147),e.beginPath(),e.moveTo(920,0),e.lineTo(920,696),e.stroke();let o=660,r=240;e.drawImage(a,2492,1181,400,100,1095,20,400,100),e.drawImage(a,2362,1360,o,r,965,180,o,r),e.drawImage(a,2362,1685,o,r,965,450,o,r)}},S={file:{type:"pdf",page:1,rotation:0},width:1819,crop(d,e,a){e.drawImage(a,264,386,1110,784,0,0,985,696),e.beginPath(),e.moveTo(1e3,0),e.lineTo(1e3,d.height),e.stroke();let o=600,r=240;e.drawImage(a,272,1894,o,120,1020,0,o,120),e.drawImage(a,272,1264,o,r,1020,180,o,r),e.drawImage(a,272,1604,o,r,1020,450,o,r),e.drawImage(a,1222,1350,155,575,1660,0,155,575)}},z={file:{type:"pdf",page:1,rotation:0},width:1217,crop(d,e,a){e.drawImage(a,55,95,1078,211,0,0,900,176),e.drawImage(a,55,367,1078,325,0,210,900,271),e.drawImage(a,55,753,1078,202,0,527,900,169),e.beginPath(),e.moveTo(920,0),e.lineTo(920,696),e.stroke(),e.rotate(-Math.PI/2),e.drawImage(a,246,1036,696,250,0,960,-696,250),e.rotate(Math.PI/2)}},M={file:{type:"pdf",page:1,rotation:0},width:1217,crop(d,e,a){e.drawImage(a,55,95,1078,211,0,0,900,176),e.drawImage(a,55,367,1078,325+40,0,200,900,305),e.drawImage(a,55,753+40,1078,202,0,527,900,169),e.beginPath(),e.moveTo(920,0),e.lineTo(920,696),e.stroke(),e.rotate(-Math.PI/2),e.drawImage(a,246,1036+40,696,250,0,960,-696,250),e.rotate(Math.PI/2)}},B={file:{type:"pdf",page:1,rotation:0},width:1217,crop(d,e,a){e.drawImage(a,55,95,1078,211+32,0,0,900,203),e.drawImage(a,55,367+32,1078,325,0,230,900,271),e.drawImage(a,55,753+32,1078,202,0,527,900,169),e.beginPath(),e.moveTo(920,0),e.lineTo(920,696),e.stroke(),e.rotate(-Math.PI/2),e.drawImage(a,246,1036+32,696,250,0,960,-696,250),e.rotate(Math.PI/2)}},D={file:{type:"pdf",page:1,rotation:0},width:1217,crop(d,e,a){e.drawImage(a,55,95,1078,211+32,0,0,900,203),e.drawImage(a,55,367+32,1078,365,0,210,900,305),e.drawImage(a,55,753+40+32,1078,202,0,527,900,169),e.beginPath(),e.moveTo(920,0),e.lineTo(920,696),e.stroke(),e.rotate(-Math.PI/2),e.drawImage(a,246,1036+40+32,696,250,0,960,-696,250),e.rotate(Math.PI/2)}},E=!1;console.log("Application loaded. debug =",E);document.getElementById("view");let i,s;convertLabel.addEventListener("click",N,!1);downloadLabel.addEventListener("click",A,!1);downloadLabelIMG.addEventListener("click",R,!1);function R(){w.exports.saveAs(new Blob([s],{type:"image/png"}),document.getElementById("file-input").files[0].name.replace(/(.pdf|.gif)/g,"")+"-Label.png")}async function A(){const d=await F();w.exports.saveAs(new Blob([d],{type:"application/pdf"}),document.getElementById("file-input").files[0].name.replace(/(.pdf|.gif)/g,"")+"-Label.pdf")}async function F(){const d=await h.create(),e=t(i.width)+n(6),a=n(62),o=d.addPage([e,a]),r=await d.embedPng(s);return o.drawImage(r,{x:n(3),y:n(1.5),width:e-n(6),height:a-n(3)}),d.save();function n(l){return l*.03937007874*72}function t(l){return l*72/300}}function N(){i=g(document.getElementById("label-type").value);const d=new FileReader;switch(console.log("Reading file."),i.file.type){case"pdf":d.readAsArrayBuffer(document.getElementById("file-input").files[0]);break;case"gif":d.readAsDataURL(document.getElementById("file-input").files[0]);break}d.onload=async e=>{var a={image:new Image};switch(i.file.type){case"pdf":a.pdf=await p.exports.getDocument(d.result).promise,console.log("PDF loaded.",a.pdf),a.page=await a.pdf.getPage(i.file.page),a.canvas=document.createElement("canvas");const n=a.page.getViewport({scale:i.scale||4,rotation:i.file.rotation});a.canvas.width=n.width,a.canvas.height=n.height,await a.page.render({canvasContext:a.canvas.getContext("2d"),viewport:n}).promise;const t=new Promise(l=>a.image.onload=l);a.image.src=a.canvas.toDataURL(),await t;break;case"gif":a.image.src=d.result;break}await new Promise(n=>setTimeout(n,100));const o=document.createElement("canvas"),r=o.getContext("2d");o.width=i.width,o.height=696,r.fillStyle="white",r.fillRect(0,0,o.width,o.height),r.strokeStyle="black",r.lineWidth=2,i.crop(o,r,a.image),console.log("Label cropped."),view.classList.add("invisible"),labelImg.src=o.toDataURL(),o.toBlob(n=>{const t=new FileReader;t.addEventListener("loadend",()=>{s=t.result,view.classList.remove("invisible")}),t.readAsArrayBuffer(n)},"image/png"),console.log("Finished.")}} diff --git a/assets/index.bf17cde9.js b/assets/index.bf17cde9.js deleted file mode 100644 index e79b8bf..0000000 --- a/assets/index.bf17cde9.js +++ /dev/null @@ -1 +0,0 @@ -import{F as g,P as m}from"./vendor.b3b4cbce.js";import{p as f}from"./vendor.pdfjs.df470f9c.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const t of n.addedNodes)t.tagName==="LINK"&&t.rel==="modulepreload"&&o(t)}).observe(document,{childList:!0,subtree:!0});function a(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerpolicy&&(n.referrerPolicy=r.referrerpolicy),r.crossorigin==="use-credentials"?n.credentials="include":r.crossorigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function o(r){if(r.ep)return;r.ep=!0;const n=a(r);fetch(r.href,n)}})();function u(d){switch(d){case"dhl-privat":return b;case"dhl-privat-international":return v;case"dhl-privat-international-native":return P;case"dhl-retoure":return T;case"dp-briefmarke":return y;case"dp-briefmarke-short":return k;case"dp-briefmarke-adresse":return L;case"hermes-privat-v102":return S;case"adidas":return M;case"mediamarkt-saturn":return z;case"nike-dhl":return B;case"dhl-nl-4-4":return E;case"dhl-nl-4-5":return D;case"dhl-nl-5-4":return A;case"dhl-nl-5-5":return F;default:console.error("Unknown label type.")}}const b={file:{type:"pdf",page:1,rotation:90},width:1642,crop(d,e,a){e.drawImage(a,1964,106,1124,94,0,0,890,74),e.drawImage(a,1964,210,785,625,0,95,580,465);let o=296;e.drawImage(a,2763,215,o,o,594,90,o,o),e.rotate(-Math.PI/2),e.drawImage(a,3075,244,20,194,-395,645,-20,194),e.rotate(Math.PI/2),e.drawImage(a,2802,679,234,154,666,465,152,100),e.drawImage(a,1964,933,1124,152,0,576,890,120),e.beginPath(),e.moveTo(910,0),e.lineTo(910,d.height),e.stroke();let r=710,n=320;e.drawImage(a,2181,1526,r,n,930,20,r,n),e.drawImage(a,2181,1940,r,n,930,376,r,n)}},v={file:{type:"pdf",page:1,rotation:90},width:2232,crop(d,e,a){e.drawImage(a,1964,106,1124,94,0,0,890,74),e.drawImage(a,1964,210,785,625,0,95,580,465);let o=296;e.drawImage(a,2763,215,o,o,594,90,o,o),e.rotate(-Math.PI/2),e.drawImage(a,3075,244,20,194,-395,645,-20,194),e.rotate(Math.PI/2),e.drawImage(a,2768,743,300,60,590,495,300,60),e.drawImage(a,1964,933,1124,152,0,576,890,120),e.beginPath(),e.moveTo(910,0),e.lineTo(910,d.height),e.stroke(),e.rotate(-Math.PI/2),e.drawImage(a,1964,854,1124,70,-696,920,696,43),e.drawImage(a,1964,1197,1124,122,-696,986,696,76),e.rotate(Math.PI/2),e.drawImage(a,2846,530,130,202,930,10,130,202),e.beginPath(),e.moveTo(920,230),e.lineTo(1070,230),e.stroke(),e.beginPath(),e.moveTo(970,240),e.lineTo(970,d.height),e.stroke(),e.beginPath(),e.moveTo(1080,0),e.lineTo(1080,d.height),e.stroke();let r=1124,n=280;e.drawImage(a,1964,1422,r,70,1100,4,r,70),e.drawImage(a,1964,1634,r,n,1100,100,r,n),e.drawImage(a,1964,2e3,160,n-20,1100,416,160,n-20),e.drawImage(a,1964,2048+260,160,20,1100,416+260,160,20),e.drawImage(a,1964+160,2048,r-160,n,1100+160,416,r-160,n)}},P={file:{type:"pdf",page:1,rotation:90},width:1878,crop(d,e,a){e.drawImage(a,1964,108,1124,92,0,12,890,73),e.drawImage(a,1964,210,785,625,0,90,580,465);let o=296;e.drawImage(a,2763,215,o,o,594,95,o,o),e.rotate(-Math.PI/2),e.drawImage(a,3075,244,20,194,-395,645,-20,194),e.rotate(Math.PI/2),e.drawImage(a,2768,743,300,60,590,495,300,60),e.drawImage(a,1964,933,1124,152,0,565,890,120),e.beginPath(),e.moveTo(910,12),e.lineTo(910,d.height-12),e.stroke();let r=940,n=270;e.drawImage(a,1964,1422,r,70,930,15,r,70),e.drawImage(a,2066,1644,r,n,936,110,r,n),e.drawImage(a,2066,2058,r,n,936,416,r,n)}},T={file:{type:"pdf",page:1,rotation:90},width:1642,crop(d,e,a){e.drawImage(a,2020,85,500,70,0,12,450,63),e.drawImage(a,2780,85,250,70,425,12,225,63),e.drawImage(a,2020,162,720,200,0,90,648,180),e.drawImage(a,2020,435,720,270,0,280,648,243),e.beginPath(),e.moveTo(0,580),e.lineTo(650,580),e.stroke(),e.drawImage(a,2020,745,720,110,0,590,648,99),e.beginPath(),e.moveTo(665,12),e.lineTo(665,d.height-12),e.stroke();let o=950,r=240;e.drawImage(a,2030,1230,o,120,686,15,o,120),e.drawImage(a,2030,1460,o,r,686,170,o,r),e.drawImage(a,2030,1810,o,r,686,445,o,r)}},y={file:{type:"pdf",page:1,rotation:90},scale:4.1666,width:402,crop(d,e,a){e.drawImage(a,17,11,402,696,0,0,402,696)}},k={file:{type:"pdf",page:1,rotation:90},scale:4.1666,width:283,crop(d,e,a){e.drawImage(a,136,11,283,696,0,0,283,696)}},L={file:{type:"pdf",page:1,rotation:90},scale:4.1666,width:874,crop(d,e,a){e.drawImage(a,64,18,874,696,0,0,874,696)}},S={file:{type:"pdf",page:1,rotation:0},width:1701,crop(d,e,a){e.drawImage(a,185,180,915,45,20,20,915,45),e.drawImage(a,200,1115,770,350,20,80,770,350),e.drawImage(a,1625,165,485,80,40,460,364,60),e.drawImage(a,1100,280,350,95,130,540,313,85),e.rotate(Math.PI/2),e.drawImage(a,2140,350,70,1020,650,-20,35,-510),e.rotate(-Math.PI/2),e.drawImage(a,1100,425,580,260,810,100,493,221),e.drawImage(a,780,870,250,220,560,370,225,198),e.drawImage(a,1100,865,580,260,810,370,493,221),e.drawImage(a,1100,1245,580,40,810,630,493,34),e.drawImage(a,1850,1325,230,140,645,600,138,84),e.drawImage(a,1640,1330,110,140,560,600,66,84),e.drawImage(a,210,370,370,640,1320,28,370,640),e.lineWidth=4,e.beginPath(),e.moveTo(0,2),e.lineTo(this.width,2),e.stroke(),e.beginPath(),e.moveTo(0,d.height-2),e.lineTo(this.width,d.height-2),e.stroke(),e.beginPath(),e.moveTo(2,4),e.lineTo(2,d.height-4),e.stroke(),e.beginPath(),e.moveTo(this.width-2,4),e.lineTo(this.width-2,d.height-4),e.stroke()}},M={file:{type:"pdf",page:1,rotation:0},width:1346,crop(d,e,a){e.drawImage(a,354,63,824,54,0,12,648,42),e.beginPath(),e.moveTo(0,65),e.lineTo(650,65),e.stroke(),e.drawImage(a,86,128,648,190,0,90,648,190),e.drawImage(a,86,319,527,262,0,280,527,262),e.drawImage(a,785,319,121,262,527,280,121,262),e.beginPath(),e.moveTo(0,580),e.lineTo(650,580),e.stroke(),e.drawImage(a,96,680,1010,140,0,590,648,90),e.beginPath(),e.moveTo(665,12),e.lineTo(665,d.height-12),e.stroke();let o=610,r=240;e.drawImage(a,1390,616,o,80,715,15,o,80),e.drawImage(a,1400,816,420,54,735,100,311,40),e.drawImage(a,170,952,o,r,715,180,o,r),e.drawImage(a,170,1326,o,r,715,445,o,r)}},z={file:{type:"pdf",page:3,rotation:90},width:1642,crop(d,e,a){e.drawImage(a,2188,243,1010,60,0,12,900,53),e.beginPath(),e.moveTo(0,75),e.lineTo(900,75),e.stroke(),e.drawImage(a,2197,361,150,376,0,100,150,376),e.drawImage(a,2419,361,750,376,150,100,750,376),e.beginPath(),e.moveTo(0,520),e.lineTo(900,520),e.stroke(),e.drawImage(a,2180,875,1010,165,0,530,900,147),e.beginPath(),e.moveTo(920,0),e.lineTo(920,696),e.stroke();let o=660,r=240;e.drawImage(a,2492,1181,400,100,1095,20,400,100),e.drawImage(a,2362,1360,o,r,965,180,o,r),e.drawImage(a,2362,1685,o,r,965,450,o,r)}},B={file:{type:"pdf",page:1,rotation:0},width:1819,crop(d,e,a){e.drawImage(a,264,386,1110,784,0,0,985,696),e.beginPath(),e.moveTo(1e3,0),e.lineTo(1e3,d.height),e.stroke();let o=600,r=240;e.drawImage(a,272,1894,o,120,1020,0,o,120),e.drawImage(a,272,1264,o,r,1020,180,o,r),e.drawImage(a,272,1604,o,r,1020,450,o,r),e.drawImage(a,1222,1350,155,575,1660,0,155,575)}},E={file:{type:"pdf",page:1,rotation:0},width:1217,crop(d,e,a){e.drawImage(a,55,95,1078,211,0,0,900,176),e.drawImage(a,55,367,1078,325,0,210,900,271),e.drawImage(a,55,753,1078,202,0,527,900,169),e.beginPath(),e.moveTo(920,0),e.lineTo(920,696),e.stroke(),e.rotate(-Math.PI/2),e.drawImage(a,246,1036,696,250,0,960,-696,250),e.rotate(Math.PI/2)}},D={file:{type:"pdf",page:1,rotation:0},width:1217,crop(d,e,a){e.drawImage(a,55,95,1078,211,0,0,900,176),e.drawImage(a,55,367,1078,325+40,0,200,900,305),e.drawImage(a,55,753+40,1078,202,0,527,900,169),e.beginPath(),e.moveTo(920,0),e.lineTo(920,696),e.stroke(),e.rotate(-Math.PI/2),e.drawImage(a,246,1036+40,696,250,0,960,-696,250),e.rotate(Math.PI/2)}},A={file:{type:"pdf",page:1,rotation:0},width:1217,crop(d,e,a){e.drawImage(a,55,95,1078,211+32,0,0,900,203),e.drawImage(a,55,367+32,1078,325,0,230,900,271),e.drawImage(a,55,753+32,1078,202,0,527,900,169),e.beginPath(),e.moveTo(920,0),e.lineTo(920,696),e.stroke(),e.rotate(-Math.PI/2),e.drawImage(a,246,1036+32,696,250,0,960,-696,250),e.rotate(Math.PI/2)}},F={file:{type:"pdf",page:1,rotation:0},width:1217,crop(d,e,a){e.drawImage(a,55,95,1078,211+32,0,0,900,203),e.drawImage(a,55,367+32,1078,365,0,210,900,305),e.drawImage(a,55,753+40+32,1078,202,0,527,900,169),e.beginPath(),e.moveTo(920,0),e.lineTo(920,696),e.stroke(),e.rotate(-Math.PI/2),e.drawImage(a,246,1036+40+32,696,250,0,960,-696,250),e.rotate(Math.PI/2)}},R=!1;console.log("Application loaded. debug =",R);document.getElementById("view");let l,I;convertLabel.addEventListener("click",Y,!1);downloadLabel.addEventListener("click",C,!1);downloadLabelIMG.addEventListener("click",N,!1);function N(){g.exports.saveAs(new Blob([I],{type:"image/png"}),document.getElementById("file-input").files[0].name.replace(".pdf","")+"-Label.png")}async function C(){const d=await X();g.exports.saveAs(new Blob([d],{type:"application/pdf"}),document.getElementById("file-input").files[0].name.replace(".pdf","")+"-Label.pdf")}async function X(){const d=await m.create(),e=t(l.width)+n(6),a=n(62),o=d.addPage([e,a]),r=await d.embedPng(I);return o.drawImage(r,{x:n(3),y:n(1.5),width:e-n(6),height:a-n(3)}),d.save();function n(s){return s*.03937007874*72}function t(s){return s*72/300}}function Y(){l=u(document.getElementById("label-type").value);const d=new FileReader;console.log("Reading file."),d.readAsArrayBuffer(document.getElementById("file-input").files[0]),d.onload=async e=>{const a=await f.exports.getDocument(d.result).promise;console.log("PDF loaded.",a);const o=await a.getPage(l.file.page),r=document.createElement("canvas"),n=o.getViewport({scale:l.scale||4,rotation:l.file.rotation});r.width=n.width,r.height=n.height,await o.render({canvasContext:r.getContext("2d"),viewport:n}).promise;const t=new Image,s=new Promise(h=>t.onload=h);t.src=r.toDataURL(),await s,await new Promise(h=>setTimeout(h,100));const i=document.createElement("canvas"),w=i.getContext("2d");i.width=l.width,i.height=696,w.fillStyle="white",w.fillRect(0,0,i.width,i.height),w.strokeStyle="black",w.lineWidth=2,l.crop(i,w,t),console.log("Label cropped."),view.classList.add("invisible"),labelImg.src=i.toDataURL(),i.toBlob(h=>{const p=new FileReader;p.addEventListener("loadend",()=>{I=p.result,view.classList.remove("invisible")}),p.readAsArrayBuffer(h)},"image/png"),console.log("Finished.")}} diff --git a/index.html b/index.html index 6af7172..a028dc7 100644 --- a/index.html +++ b/index.html @@ -17,7 +17,7 @@ - + @@ -95,6 +95,9 @@ + @@ -137,12 +140,12 @@
PDF, GIF