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