MCPcopy Create free account
hub / github.com/32comic/image2pixel-web / printFromDataURL

Method printFromDataURL

pixelizer.js:1048–1098  ·  view source on GitHub ↗
(dataURL)

Source from the content-addressed store, hash-verified

1046 }
1047
1048 printFromDataURL(dataURL) {
1049 const printWindow = window.open('', '_blank');
1050 printWindow.document.write(`
1051 <!DOCTYPE html>
1052 <html>
1053 <head>
1054 <title>Print Pixel Art</title>
1055 <style>
1056 @page {
1057 size: A4;
1058 margin: 0.5cm;
1059 }
1060 body {
1061 margin: 0;
1062 padding: 0;
1063 display: flex;
1064 justify-content: center;
1065 align-items: center;
1066 min-height: 100vh;
1067 background: #f0f0f0;
1068 }
1069 img {
1070 max-width: 100%;
1071 max-height: 100vh;
1072 border: 1px solid #ccc;
1073 box-shadow: 0 2px 10px rgba(0,0,0,0.1);
1074 image-rendering: pixelated;
1075 image-rendering: -moz-crisp-edges;
1076 image-rendering: crisp-edges;
1077 object-fit: contain;
1078 }
1079 @media print {
1080 body { background: white; }
1081 img { border: none; box-shadow: none; }
1082 }
1083 </style>
1084 </head>
1085 <body>
1086 <img src="${dataURL}" alt="Pixel Art for Printing">
1087 </body>
1088 </html>
1089 `);
1090
1091 printWindow.document.close();
1092 printWindow.onload = function() {
1093 setTimeout(() => {
1094 printWindow.print();
1095 printWindow.close();
1096 }, 250);
1097 };
1098 }
1099
1100 updatePreviewIfNeeded() {
1101 // 如果已经有处理结果,实时更新预览

Callers 1

printResultMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected