stock module latest today vadivel J 22-01-2025

This commit is contained in:
vadivelJ96 2025-01-22 11:32:29 +05:30
parent fe8f187c89
commit 7d4e0aed1c
2 changed files with 50 additions and 27 deletions

View File

@ -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.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>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.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>
<!-- !-- 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/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>
<!-- JSZip for Excel export -->

View File

@ -617,7 +617,7 @@
<main>
<table class="side-table" border="1" width="100%">
<table class="side-table" id="basicDetailsTableId" border="1" width="100%">
<thead>
</thead>
@ -1163,32 +1163,55 @@
<!-- download pdf punction -->
<script>
document.getElementById('pdfGenerateId').addEventListener('click', function () {
// Get the content
const content = document.getElementById("content").innerHTML;
// Sanitize with DOMPurify
const cleanContent = DOMPurify.sanitize(content);
// 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');
document.getElementById('pdfGenerateId').addEventListener('click', function () {
const { jsPDF } = window.jspdf;
const doc = new jsPDF({
orientation: 'portrait',
unit: 'pt',
format: 'A4'
});
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>
<!-- Save All Data in Incoming Silica Sand Details -->
<script type="text/javascript">