eLabSDK.Export.PDF
render()
Generate and download the PDF file.
This submits the PDF generation request to the server with the configured HTML content and
filename. The PDF is generated server-side and automatically downloaded to the user's browser.
After submission, the temporary form is removed from the DOM. Call this method after creating
an eLabSDK.Export.PDF instance to trigger the actual PDF creation and download.
Kind: global function
Example
// Generate a simple PDF
eLabSDK.ready(function() {
var exportPDF = new eLabSDK.Export.PDF({
name: 'MyReport.pdf',
contents: '<h1>My Report</h1><p>This is the content of my report.</p>'
});
exportPDF.render(); // Triggers PDF generation and download
});
Example
// Generate PDF with custom logo
eLabSDK.ready(function() {
var exportPDF = new eLabSDK.Export.PDF({
name: 'LabReport.pdf',
contents: '<h1>Lab Results</h1><table>...</table>',
useGroupLogo: true,
logoDimensions: {
height: 60,
width: 60,
left: 520,
bottom: 770,
right: 100,
top: 20
}
});
exportPDF.render();
});
Example
// Export current page content as PDF
eLabSDK.ready(function() {
$('#exportPdfBtn').on('click', function() {
var pageContent = $('#mainContent').html();
var exportPDF = new eLabSDK.Export.PDF({
name: 'PageExport_' + new Date().getTime() + '.pdf',
contents: pageContent
});
exportPDF.render();
console.log('PDF export initiated');
});
});
Example
// Generate PDF from table data
eLabSDK.ready(function() {
function exportTableAsPDF() {
var html = '<h1>Sample Data Export</h1>';
html += '<table border="1" style="border-collapse: collapse;">';
html += '<tr><th>Sample ID</th><th>Name</th><th>Status</th></tr>';
$('#sampleTable tbody tr').each(function() {
var $row = $(this);
html += '<tr>';
$row.find('td').each(function() {
html += '<td>' + $(this).text() + '</td>';
});
html += '</tr>';
});
html += '</table>';
var exportPDF = new eLabSDK.Export.PDF({
name: 'SampleData_' + new Date().toISOString().split('T')[0] + '.pdf',
contents: html,
useGroupLogo: true
});
exportPDF.render();
}
$('#exportTableBtn').on('click', exportTableAsPDF);
});
© 2023 eLabNext
Updated about 6 hours ago