myarkqub

Ads

Nov 23rd, 2025
694
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.86 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. <head>
  5.     <meta charset="UTF-8" />
  6.     <title>Address Delivery Sticker</title>
  7.     <style>
  8.         /* For screen */
  9.         canvas {
  10.             border: 1px solid black;
  11.         }
  12.  
  13.         /* For printing */
  14.         @media print {
  15.             @page {
  16.                 size: landscape;
  17.                 margin: 0;
  18.             }
  19.  
  20.             canvas {
  21.                 width: 250mm;
  22.                 /* physical printed width */
  23.                 height: 180mm;
  24.                 /* printed height */
  25.                 display: block;
  26.                 margin: auto;
  27.             }
  28.         }
  29.     </style>
  30. </head>
  31.  
  32. <body>
  33.     <form id="form_">
  34.         TO: <input type="text" name="to"> <br>
  35.         Store Code: <input type="text" name="store_code"> <br>
  36.         Store Name: <input type="text" name="store_name"> <br>
  37.         File Name: <select name="file_name">
  38.             <option value="DMO">DMO</option>
  39.             <option value="DMC">DMC</option>
  40.             <option value="DDR">DDR</option>
  41.             <option value="SCB_SRD">SCB/SRD</option>
  42.             <option value="BY_HAND_QUALITY_ISSUE_DMQ">BY HAND - QUALITY ISSUE (DMQ)</option>
  43.             <option value="DMW">DMW</option>
  44.             <option value="DMN">DMN</option>
  45.             <option value="DMP">DMP</option>
  46.             <option value="RETURNABLE_SKUs">RETURNABLE SKUs</option>
  47.         </select> <br>
  48.         <!-- DMO, DMC, DDR, SCB/SRD, BY HAND - QUALITY ISSUE (DMQ), DMW, DMN, DMP, RETURNABLE SKUs -->
  49.         DM File Date: <input type="date" name="dm_file_date"> <br>
  50.         Total Cartons: <input type="number" name="total_cartons"> <br>
  51.         Remarks: <textarea name="remarks"></textarea> <br>
  52.         <input type="submit" value="Generate">
  53.         <div id="printArea" style="display:none"></div>
  54.     </form>
  55.     <canvas id="canvas_" style="border:1px solid #000000;"></canvas>
  56.     <script>
  57.         const form_ = document.getElementById("form_")
  58.         const canvas_ = document.getElementById("canvas_")
  59.         const printArea_ = document.getElementById("printArea")
  60.         const ctx = canvas_.getContext("2d");
  61.         //premake_delivery_sticker(ctx);
  62.         ctx.fillText("Address Delivery Sticker", 10, 10);
  63.        
  64.  
  65.         //generate sticker on submit
  66.         form_.addEventListener('submit', (e) => {
  67.             e.preventDefault();
  68.             // console.log("Submitted")
  69.             // console.log(form_.to.value)
  70.             //print canvas
  71.             const dataURL = canvas_.toDataURL("image/png");
  72.             printArea_.innerHTML = `<img src="${dataURL}">`;
  73.             printArea_.style.display = "block";
  74.             form_.style.display = "none";
  75.             window.print();
  76.             // Hide again after printing
  77.             printArea_.style.display = "none";
  78.             form_.style.display = "block";
  79.         })
  80.     </script>
  81. </body>
  82.  
  83. </html>
Advertisement
Add Comment
Please, Sign In to add comment