Pull Request branch dev-clone to main #1
|
|
@ -362,36 +362,29 @@ export default function AssessmentResultPage() {
|
||||||
|
|
||||||
const handlePrintPDF = async (isSuperAdmin: boolean) => {
|
const handlePrintPDF = async (isSuperAdmin: boolean) => {
|
||||||
const pdfContainer = document.getElementById("pdfContainer");
|
const pdfContainer = document.getElementById("pdfContainer");
|
||||||
const targetCard = document.getElementById("target-card");
|
|
||||||
const barChart = document.getElementById("bar-chart");
|
|
||||||
|
|
||||||
if (pdfContainer && targetCard && barChart) {
|
if (pdfContainer) {
|
||||||
// Sembunyikan elemen yang tidak ingin dicetak
|
// Sembunyikan elemen yang tidak ingin dicetak
|
||||||
const buttonPrint = document.getElementById("button-print");
|
const buttonPrint = document.getElementById("button-print");
|
||||||
const noPrint = document.getElementById("no-print");
|
const noPrint = document.getElementById("no-print");
|
||||||
if (buttonPrint) buttonPrint.style.visibility = 'hidden';
|
if (buttonPrint) buttonPrint.style.visibility = 'hidden';
|
||||||
if (noPrint) noPrint.style.visibility = 'hidden';
|
if (noPrint) noPrint.style.visibility = 'hidden';
|
||||||
|
|
||||||
// Tentukan marginTop sesuai dengan isSuperAdmin
|
const pdfMargin = isSuperAdmin ? [10, 10, 10, -220] : [10, 10, 10, -230];
|
||||||
const originalMarginTop = targetCard.style.marginTop || "0px";
|
const pdfWidth = isSuperAdmin ? 1575 : 1550;
|
||||||
targetCard.style.marginTop = isSuperAdmin ? "190px" : "0px";
|
|
||||||
|
|
||||||
// Tentukan marginTop sesuai dengan isSuperAdmin
|
|
||||||
const originalBarChart = barChart.style.marginTop || "0px";
|
|
||||||
barChart.style.marginTop = isSuperAdmin ? "0px" : "150px";
|
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
margin: [0, 0.5, 0, 0],
|
margin: pdfMargin,
|
||||||
image: { type: 'jpeg', quality: 0.98 },
|
image: { type: 'jpeg', quality: 0.98 },
|
||||||
html2canvas: {
|
html2canvas: {
|
||||||
scale: 2,
|
scale: 2,
|
||||||
width: pdfContainer.scrollWidth,
|
width: pdfWidth, // Lebar tetap untuk ukuran A4 (landscape)
|
||||||
height: pdfContainer.scrollHeight,
|
height: pdfContainer.scrollHeight, // Tinggi dinamis sesuai konten
|
||||||
},
|
},
|
||||||
jsPDF: {
|
jsPDF: {
|
||||||
unit: 'in',
|
unit: 'pt',
|
||||||
format: 'a4',
|
format: 'a4',
|
||||||
orientation: 'landscape',
|
orientation: 'portrait',
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -416,10 +409,6 @@ export default function AssessmentResultPage() {
|
||||||
// Tampilkan kembali elemen yang disembunyikan
|
// Tampilkan kembali elemen yang disembunyikan
|
||||||
if (buttonPrint) buttonPrint.style.visibility = 'visible';
|
if (buttonPrint) buttonPrint.style.visibility = 'visible';
|
||||||
if (noPrint) noPrint.style.visibility = 'visible';
|
if (noPrint) noPrint.style.visibility = 'visible';
|
||||||
|
|
||||||
// Reset marginTop ke nilai aslinya
|
|
||||||
targetCard.style.marginTop = originalMarginTop || "0px";
|
|
||||||
barChart.style.marginTop = originalBarChart || "0px";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user