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,86 +54,135 @@ 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;
|
||||||
|
const logoX = 10;
|
||||||
|
const logoY = 10;
|
||||||
|
|
||||||
// Add the table for names and roles (Using courseData for this)
|
const loadImage = async (url) => {
|
||||||
const table1Data = [
|
const response = await fetch(url);
|
||||||
...(courseData.oralPracticalTeachers?.map((teacher) => [
|
const blob = await response.blob();
|
||||||
teacher,
|
return new Promise((resolve, reject) => {
|
||||||
"K. J. Somaiya Institute of Technology",
|
const reader = new FileReader();
|
||||||
"Assessment Role",
|
reader.onload = () => resolve(reader.result);
|
||||||
"Contact Number",
|
reader.onerror = (error) => reject(error);
|
||||||
]) || []),
|
reader.readAsDataURL(blob);
|
||||||
...(courseData.reassessmentTeachers?.map((teacher) => [
|
});
|
||||||
teacher,
|
};
|
||||||
"K. J. Somaiya Institute of Technology",
|
|
||||||
"Reassessment Role",
|
|
||||||
"Contact Number",
|
|
||||||
]) || []),
|
|
||||||
...(courseData.paperSettingTeachers?.map((teacher) => [
|
|
||||||
teacher,
|
|
||||||
"K. J. Somaiya Institute of Technology",
|
|
||||||
"Paper Setter",
|
|
||||||
"Contact Number",
|
|
||||||
]) || []),
|
|
||||||
...(courseData.moderationTeachers?.map((teacher) => [
|
|
||||||
teacher,
|
|
||||||
"K. J. Somaiya Institute of Technology",
|
|
||||||
"Moderator",
|
|
||||||
"Contact Number",
|
|
||||||
]) || []),
|
|
||||||
...(courseData.pwdPaperSettingTeachers?.map((teacher) => [
|
|
||||||
teacher,
|
|
||||||
"K. J. Somaiya Institute of Technology",
|
|
||||||
"PwD Paper Setter",
|
|
||||||
"Contact Number",
|
|
||||||
]) || []),
|
|
||||||
];
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
const logoBase64 = await loadImage(logoUrl);
|
||||||
|
doc.addImage(logoBase64, "PNG", logoX, logoY, logoWidth, logoHeight);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to load logo:", error);
|
||||||
|
}
|
||||||
|
|
||||||
autoTable(doc, {
|
// Title Section
|
||||||
head: [["Name", "Affiliation", "Appointment Role", "Contact No."]],
|
doc.setFont("times", "normal");
|
||||||
body: table1Data,
|
doc.setTextColor(0, 0, 0);
|
||||||
startY: 20,
|
doc.setFontSize(12);
|
||||||
theme: "grid",
|
doc.text("Date: " + new Date().toLocaleDateString(), 150, 20);
|
||||||
});
|
doc.setFontSize(14);
|
||||||
|
doc.text("CONFIDENTIAL", 10, 60);
|
||||||
|
doc.setFontSize(16);
|
||||||
|
doc.text(
|
||||||
|
"LETTER OF APPOINTMENT AS QUESTION PAPER SETTER",
|
||||||
|
105,
|
||||||
|
70,
|
||||||
|
{ align: "center" }
|
||||||
|
);
|
||||||
|
|
||||||
// Add the descriptive paragraph
|
// Appointment Table
|
||||||
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:`;
|
const table1Data = [
|
||||||
doc.setFontSize(12);
|
...(courseData.oralPracticalTeachers?.map((teacher) => [
|
||||||
doc.text(text, 10, doc.previousAutoTable.finalY + 10);
|
teacher,
|
||||||
|
"K. J. Somaiya School of Engineering",
|
||||||
|
"Oral/Practical Teacher",
|
||||||
|
"Contact Number",
|
||||||
|
]) || []),
|
||||||
|
...(courseData.reassessmentTeachers?.map((teacher) => [
|
||||||
|
teacher,
|
||||||
|
"K. J. Somaiya School of Engineering",
|
||||||
|
"Reassessment Teacher",
|
||||||
|
"Contact Number",
|
||||||
|
]) || []),
|
||||||
|
...(courseData.paperSettingTeachers?.map((teacher) => [
|
||||||
|
teacher,
|
||||||
|
"K. J. Somaiya School of Engineering",
|
||||||
|
"Paper Setter",
|
||||||
|
"Contact Number",
|
||||||
|
]) || []),
|
||||||
|
...(courseData.moderationTeachers?.map((teacher) => [
|
||||||
|
teacher,
|
||||||
|
"K. J. Somaiya School of Engineering",
|
||||||
|
"Moderator",
|
||||||
|
"Contact Number",
|
||||||
|
]) || []),
|
||||||
|
...(courseData.pwdPaperSettingTeachers?.map((teacher) => [
|
||||||
|
teacher,
|
||||||
|
"K. J. Somaiya School of Engineering",
|
||||||
|
"PwD Paper Setter",
|
||||||
|
"Contact Number",
|
||||||
|
]) || []),
|
||||||
|
];
|
||||||
|
|
||||||
// Add the exam details table using `courseData`
|
autoTable(doc, {
|
||||||
const table2Data = [
|
head: [["Name", "Affiliation", "Appointment Role", "Email"]],
|
||||||
["Programme:", courseData.courseName],
|
body: table1Data,
|
||||||
["Exam Category:", "Regular Examination"],
|
startY: 80,
|
||||||
["Exam Type:", courseData.examType],
|
theme: "grid",
|
||||||
["Exam Season:", "Second Half - Winter Examination 2023"],
|
headStyles: { fillColor: maroon, textColor: [255, 255, 255] },
|
||||||
["Number of Sets Required:", courseData.paperSettingTeachers.length],
|
styles: { textColor: [0, 0, 0] }, // Keep body text black
|
||||||
["Year:", courseData.year],
|
});
|
||||||
["Semester:", courseData.semester],
|
|
||||||
["Course Name:", courseName],
|
|
||||||
["Course Code:", courseData.courseCode],
|
|
||||||
];
|
|
||||||
|
|
||||||
|
// 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] },
|
||||||
|
});
|
||||||
|
|
||||||
autoTable(doc, {
|
// Footer Section
|
||||||
body: table2Data,
|
const footerY = doc.previousAutoTable.finalY + 10; // Dynamic Y-coordinate
|
||||||
startY: doc.previousAutoTable.finalY + 30,
|
doc.setFontSize(12);
|
||||||
theme: "plain",
|
doc.text("Dr. S. K. Ukarande", 10, footerY);
|
||||||
styles: { lineColor: [0, 0, 0], lineWidth: 0.1 },
|
doc.text("Principal", 10, footerY + 5);
|
||||||
});
|
doc.text("K. J. Somaiya School of Engineering", 10, footerY + 10);
|
||||||
|
|
||||||
// Save the PDF
|
// Footer Contact Details
|
||||||
doc.save(`${courseName} - AppointmentOrder.pdf`);
|
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 (
|
||||||
|
|||||||
Reference in New Issue
Block a user