stock module latest today vadivel J 22-01-2025
This commit is contained in:
parent
fe8f187c89
commit
7d4e0aed1c
@ -52,12 +52,12 @@
|
|||||||
<script src="https://cdn.datatables.net/buttons/2.3.6/js/buttons.html5.min.js"></script>
|
<script src="https://cdn.datatables.net/buttons/2.3.6/js/buttons.html5.min.js"></script>
|
||||||
<script src="https://cdn.datatables.net/buttons/2.3.6/js/buttons.print.min.js"></script>
|
<script src="https://cdn.datatables.net/buttons/2.3.6/js/buttons.print.min.js"></script>
|
||||||
|
|
||||||
<!-- cdn for pdf download -->
|
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.4.0/jspdf.umd.min.js"></script>
|
|
||||||
|
|
||||||
<!-- !-- cdn for pdf download -->
|
<!-- cdn for pdf download -->
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/2.4.3/purify.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.31/jspdf.plugin.autotable.min.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- JSZip for Excel export -->
|
<!-- JSZip for Excel export -->
|
||||||
|
|||||||
@ -617,7 +617,7 @@
|
|||||||
|
|
||||||
<main>
|
<main>
|
||||||
|
|
||||||
<table class="side-table" border="1" width="100%">
|
<table class="side-table" id="basicDetailsTableId" border="1" width="100%">
|
||||||
<thead>
|
<thead>
|
||||||
|
|
||||||
</thead>
|
</thead>
|
||||||
@ -1163,32 +1163,55 @@
|
|||||||
|
|
||||||
<!-- download pdf punction -->
|
<!-- download pdf punction -->
|
||||||
<script>
|
<script>
|
||||||
document.getElementById('pdfGenerateId').addEventListener('click', function () {
|
document.getElementById('pdfGenerateId').addEventListener('click', function () {
|
||||||
// Get the content
|
const { jsPDF } = window.jspdf;
|
||||||
const content = document.getElementById("content").innerHTML;
|
const doc = new jsPDF({
|
||||||
|
orientation: 'portrait',
|
||||||
// Sanitize with DOMPurify
|
unit: 'pt',
|
||||||
const cleanContent = DOMPurify.sanitize(content);
|
format: 'A4'
|
||||||
|
|
||||||
// Convert to PDF
|
|
||||||
const element = document.createElement('div');
|
|
||||||
element.innerHTML = cleanContent;
|
|
||||||
|
|
||||||
const opt = {
|
|
||||||
margin: 1,
|
|
||||||
filename: 'report.pdf',
|
|
||||||
image: { type: 'jpeg', quality: 0.98 },
|
|
||||||
html2canvas: { scale: 2 },
|
|
||||||
jsPDF: { unit: 'in', format: 'A4', orientation: 'portrait' }
|
|
||||||
};
|
|
||||||
|
|
||||||
html2pdf().from(element).set(opt).save();
|
|
||||||
|
|
||||||
$('#downloadLabReportModel').modal('hide');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const element = document.getElementById("content");
|
||||||
|
|
||||||
|
// Get PDF size
|
||||||
|
const pdfWidth = doc.internal.pageSize.getWidth();
|
||||||
|
const pdfHeight = doc.internal.pageSize.getHeight();
|
||||||
|
|
||||||
|
// Get content size
|
||||||
|
const elementWidth = element.scrollWidth;
|
||||||
|
const elementHeight = element.scrollHeight;
|
||||||
|
|
||||||
|
// Calculate scale factor to fit content inside PDF
|
||||||
|
const scaleFactor = Math.min(pdfWidth / elementWidth, pdfHeight / elementHeight);
|
||||||
|
|
||||||
|
// Calculate centering position
|
||||||
|
const centeredX = (pdfWidth - (elementWidth * scaleFactor)) / 2;
|
||||||
|
const centeredY = (pdfHeight - (elementHeight * scaleFactor)) / 2;
|
||||||
|
|
||||||
|
// Apply no extra padding to x (to remove spaces)
|
||||||
|
const trimLeft = Math.max(centeredX, 0);
|
||||||
|
const trimRight = Math.max(pdfWidth - (elementWidth * scaleFactor) - trimLeft, 0);
|
||||||
|
|
||||||
|
// Set trim margins for centering effect
|
||||||
|
doc.html(element, {
|
||||||
|
html2canvas: {
|
||||||
|
scale: scaleFactor, // Scale content to fit
|
||||||
|
useCORS: true // Enable cross-origin images
|
||||||
|
},
|
||||||
|
callback: function (doc) {
|
||||||
|
doc.save(`SandLabReport.pdf`);
|
||||||
|
},
|
||||||
|
x: trimLeft, // Adjust left padding
|
||||||
|
y: centeredY // Keep vertical centering
|
||||||
|
});
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Save All Data in Incoming Silica Sand Details -->
|
<!-- Save All Data in Incoming Silica Sand Details -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user