forked from CSI-KJSCE/appointment_to_examiner
Pdf- css
This commit is contained in:
BIN
client/public/logo.png
Normal file
BIN
client/public/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 123 KiB |
@@ -54,87 +54,136 @@ const CourseConsolidated = () => {
|
|||||||
if (currentPage > 1) setCurrentPage((prevPage) => prevPage - 1);
|
if (currentPage > 1) setCurrentPage((prevPage) => prevPage - 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
const generateAppointmentPDF = (courseData, courseName) => {
|
const generateAppointmentPDF = async (courseData, courseName) => {
|
||||||
console.log(courseData);
|
const doc = new jsPDF();
|
||||||
const doc = new jsPDF();
|
const maroon = [128, 0, 0];
|
||||||
|
|
||||||
// Add Title
|
// College Logo
|
||||||
doc.setFontSize(16);
|
const logoUrl = "/logo.png"; // Ensure the logo is placed in the public folder
|
||||||
doc.text(`${courseName} - Appointment Order`, 105, 10, { align: "center" });
|
const logoWidth = 40;
|
||||||
|
const logoHeight = 40;
|
||||||
// Add the table for names and roles (Using courseData for this)
|
const logoX = 10;
|
||||||
const table1Data = [
|
const logoY = 10;
|
||||||
...(courseData.oralPracticalTeachers?.map((teacher) => [
|
|
||||||
teacher,
|
const loadImage = async (url) => {
|
||||||
"K. J. Somaiya Institute of Technology",
|
const response = await fetch(url);
|
||||||
"Assessment Role",
|
const blob = await response.blob();
|
||||||
"Contact Number",
|
return new Promise((resolve, reject) => {
|
||||||
]) || []),
|
const reader = new FileReader();
|
||||||
...(courseData.reassessmentTeachers?.map((teacher) => [
|
reader.onload = () => resolve(reader.result);
|
||||||
teacher,
|
reader.onerror = (error) => reject(error);
|
||||||
"K. J. Somaiya Institute of Technology",
|
reader.readAsDataURL(blob);
|
||||||
"Reassessment Role",
|
});
|
||||||
"Contact Number",
|
};
|
||||||
]) || []),
|
|
||||||
...(courseData.paperSettingTeachers?.map((teacher) => [
|
try {
|
||||||
teacher,
|
const logoBase64 = await loadImage(logoUrl);
|
||||||
"K. J. Somaiya Institute of Technology",
|
doc.addImage(logoBase64, "PNG", logoX, logoY, logoWidth, logoHeight);
|
||||||
"Paper Setter",
|
} catch (error) {
|
||||||
"Contact Number",
|
console.error("Failed to load logo:", error);
|
||||||
]) || []),
|
}
|
||||||
...(courseData.moderationTeachers?.map((teacher) => [
|
|
||||||
teacher,
|
// Title Section
|
||||||
"K. J. Somaiya Institute of Technology",
|
doc.setFont("times", "normal");
|
||||||
"Moderator",
|
doc.setTextColor(0, 0, 0);
|
||||||
"Contact Number",
|
doc.setFontSize(12);
|
||||||
]) || []),
|
doc.text("Date: " + new Date().toLocaleDateString(), 150, 20);
|
||||||
...(courseData.pwdPaperSettingTeachers?.map((teacher) => [
|
doc.setFontSize(14);
|
||||||
teacher,
|
doc.text("CONFIDENTIAL", 10, 60);
|
||||||
"K. J. Somaiya Institute of Technology",
|
doc.setFontSize(16);
|
||||||
"PwD Paper Setter",
|
doc.text(
|
||||||
"Contact Number",
|
"LETTER OF APPOINTMENT AS QUESTION PAPER SETTER",
|
||||||
]) || []),
|
105,
|
||||||
];
|
70,
|
||||||
|
{ align: "center" }
|
||||||
|
);
|
||||||
autoTable(doc, {
|
|
||||||
head: [["Name", "Affiliation", "Appointment Role", "Contact No."]],
|
// Appointment Table
|
||||||
body: table1Data,
|
const table1Data = [
|
||||||
startY: 20,
|
...(courseData.oralPracticalTeachers?.map((teacher) => [
|
||||||
theme: "grid",
|
teacher,
|
||||||
});
|
"K. J. Somaiya School of Engineering",
|
||||||
|
"Oral/Practical Teacher",
|
||||||
// Add the descriptive paragraph
|
"Contact Number",
|
||||||
const text = `Dear all,\n\nYou have been appointed to jointly act as Paper Setters as mentioned against your name for the following Examination to be held at K. J. Somaiya Institute of Technology, Sion, Mumbai:`;
|
]) || []),
|
||||||
doc.setFontSize(12);
|
...(courseData.reassessmentTeachers?.map((teacher) => [
|
||||||
doc.text(text, 10, doc.previousAutoTable.finalY + 10);
|
teacher,
|
||||||
|
"K. J. Somaiya School of Engineering",
|
||||||
// Add the exam details table using `courseData`
|
"Reassessment Teacher",
|
||||||
const table2Data = [
|
"Contact Number",
|
||||||
["Programme:", courseData.courseName],
|
]) || []),
|
||||||
["Exam Category:", "Regular Examination"],
|
...(courseData.paperSettingTeachers?.map((teacher) => [
|
||||||
["Exam Type:", courseData.examType],
|
teacher,
|
||||||
["Exam Season:", "Second Half - Winter Examination 2023"],
|
"K. J. Somaiya School of Engineering",
|
||||||
["Number of Sets Required:", courseData.paperSettingTeachers.length],
|
"Paper Setter",
|
||||||
["Year:", courseData.year],
|
"Contact Number",
|
||||||
["Semester:", courseData.semester],
|
]) || []),
|
||||||
["Course Name:", courseName],
|
...(courseData.moderationTeachers?.map((teacher) => [
|
||||||
["Course Code:", courseData.courseCode],
|
teacher,
|
||||||
];
|
"K. J. Somaiya School of Engineering",
|
||||||
|
"Moderator",
|
||||||
|
"Contact Number",
|
||||||
|
]) || []),
|
||||||
autoTable(doc, {
|
...(courseData.pwdPaperSettingTeachers?.map((teacher) => [
|
||||||
body: table2Data,
|
teacher,
|
||||||
startY: doc.previousAutoTable.finalY + 30,
|
"K. J. Somaiya School of Engineering",
|
||||||
theme: "plain",
|
"PwD Paper Setter",
|
||||||
styles: { lineColor: [0, 0, 0], lineWidth: 0.1 },
|
"Contact Number",
|
||||||
});
|
]) || []),
|
||||||
|
];
|
||||||
// Save the PDF
|
|
||||||
doc.save(`${courseName} - AppointmentOrder.pdf`);
|
autoTable(doc, {
|
||||||
};
|
head: [["Name", "Affiliation", "Appointment Role", "Email"]],
|
||||||
|
body: table1Data,
|
||||||
|
startY: 80,
|
||||||
|
theme: "grid",
|
||||||
|
headStyles: { fillColor: maroon, textColor: [255, 255, 255] },
|
||||||
|
styles: { textColor: [0, 0, 0] }, // Keep body text black
|
||||||
|
});
|
||||||
|
|
||||||
|
// Content Table
|
||||||
|
const detailsTableData = [
|
||||||
|
["Programme:", courseData.courseName],
|
||||||
|
["Exam Category:", "Regular Examination"],
|
||||||
|
["Exam Type:", courseData.examType],
|
||||||
|
["Exam Season:", "Second Half - Winter Examination 2023"],
|
||||||
|
["Number of Sets Required:", courseData.paperSettingTeachers.length],
|
||||||
|
["Year:", courseData.year],
|
||||||
|
["Semester:", courseData.semester],
|
||||||
|
["Course Name:", courseName],
|
||||||
|
["Course Code:", courseData.courseCode],
|
||||||
|
];
|
||||||
|
|
||||||
|
autoTable(doc, {
|
||||||
|
body: detailsTableData,
|
||||||
|
startY: doc.previousAutoTable.finalY + 10,
|
||||||
|
theme: "plain", // Plain table style
|
||||||
|
styles: { textColor: [0, 0, 0] },
|
||||||
|
});
|
||||||
|
|
||||||
|
// Footer Section
|
||||||
|
const footerY = doc.previousAutoTable.finalY + 10; // Dynamic Y-coordinate
|
||||||
|
doc.setFontSize(12);
|
||||||
|
doc.text("Dr. S. K. Ukarande", 10, footerY);
|
||||||
|
doc.text("Principal", 10, footerY + 5);
|
||||||
|
doc.text("K. J. Somaiya School of Engineering", 10, footerY + 10);
|
||||||
|
|
||||||
|
// Footer Contact Details
|
||||||
|
const footerContactY = footerY + 20;
|
||||||
|
doc.setFontSize(10);
|
||||||
|
doc.text(
|
||||||
|
"Somaiya Vidyavihar, Vidyavihar (East), Mumbai-400 022, India",
|
||||||
|
10,
|
||||||
|
footerContactY
|
||||||
|
);
|
||||||
|
doc.text("Telephone: (91-22) 44444400, 44444404", 10, footerContactY + 5);
|
||||||
|
doc.text("Email: principal.tech@somaiya.edu", 10, footerContactY + 10);
|
||||||
|
doc.text("Web: www.somaiya.edu/kjsieit", 10, footerContactY + 15);
|
||||||
|
|
||||||
|
// Save PDF
|
||||||
|
doc.save(`${courseName} - AppointmentOrder.pdf`);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -187,7 +236,7 @@ const CourseConsolidated = () => {
|
|||||||
textDecoration: "none",
|
textDecoration: "none",
|
||||||
borderRadius: "5px",
|
borderRadius: "5px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Download {courseName}'s Appointment Order
|
Download {courseName}'s Appointment Order
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user