Professional Passport Photo Tool
Generate layout to see preview
0 photos
A4 (210 × 297 mm)
35 × 45 mm
`;
// Write to print window
printWindow.document.write(printHTML + photoCellsHTML + closingHTML);
printWindow.document.close();
} catch (e) {
console.error('Print error:', e);
alert('Error occurred while preparing print. Please try again.');
}
}
// Download the layout as PDF
function downloadLayout() {
if (!paperPreview.innerHTML.includes('photo-grid')) {
alert('Please generate a layout first.');
return;
}
// For mobile devices, suggest using the print option
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
alert('For best results on mobile, use the Print button and select "Save as PDF" in the print dialog.');
return;
}
alert('For PDF export, please use the Print button and select "Save as PDF" in the print dialog.\n\nIn a complete implementation, we would use a PDF generation library.');
}
// Initialize
updatePaperSizeInfo();
updatePhotoSizeInfo();
// Handle window resize
window.addEventListener('resize', function() {
if (paperPreview.innerHTML.includes('photo-grid')) {
generateLayout();
}
});
});