<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Portable Receipt - Print View</title> <style> body { font-size: 45px; padding: 10px; } </style> </head> <body> <div id="receipt-content"></div> <script> // Retrieve the receipt data from sessionStorage var portableReceipt = sessionStorage.getItem('portableReceipt'); // Display the receipt content in the page if (portableReceipt) { document.getElementById('receipt-content').innerHTML = portableReceipt; } else { document.getElementById('receipt-content').innerHTML = '<p>Error: Receipt data not found.</p>'; } // Automatically trigger the print dialog when the page loads window.onload = function() { setTimeout(function() { window.print(); }, 500); // Delay to allow the page to render before printing }; </script> </body> </html>