added report lab options

This commit is contained in:
2025-05-06 16:20:04 +03:00
parent fb582be590
commit 31e0ffd6dc
5 changed files with 85 additions and 5 deletions

View File

@@ -303,4 +303,43 @@ document.addEventListener('DOMContentLoaded', () => {
})
.catch(error => console.error('Error saving template:', error));
});
document.getElementById('generate-pdf-btn').addEventListener('click', () => {
const width = document.getElementById('label-width').value;
const height = document.getElementById('label-height').value;
const selectedColumns = Array.from(document.querySelectorAll('#columns-container input[type="checkbox"]:checked'))
.map(checkbox => checkbox.value);
if (!width || !height || selectedColumns.length === 0) {
alert('Please set dimensions and select at least one column.');
return;
}
const data = {
width: parseFloat(width),
height: parseFloat(height),
columns: selectedColumns
};
fetch('/generate_pdf', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(result => {
alert(result.message);
console.log('PDF Path:', result.pdf_path);
// Provide a link to download the PDF
const downloadLink = document.createElement('a');
downloadLink.href = result.pdf_path;
downloadLink.textContent = 'Download Generated PDF';
downloadLink.target = '_blank';
document.getElementById('label-preview').appendChild(downloadLink);
})
.catch(error => console.error('Error generating PDF:', error));
});
});