-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Enhance student result PDF generation by applying word wrapping to long names in the student information table #1854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3537,15 +3537,18 @@ def post(self, request): | |
| story.append(Spacer(1, 12)) | ||
|
|
||
| # Student Information Table | ||
| # Wrap long names in Paragraph to enable word wrapping | ||
| student_name = student_info.get('name', 'N/A') | ||
| if len(student_name) > 25: # If name is too long, wrap it | ||
| student_name = Paragraph(student_name, ParagraphStyle('NameStyle', parent=styles['Normal'], fontSize=10, fontName='Times-Roman')) | ||
|
|
||
| cell_style = ParagraphStyle( | ||
| 'CellStyle', | ||
| parent=styles['Normal'], | ||
| fontSize=10, | ||
| fontName='Times-Roman', | ||
| wordWrap='CJK' | ||
| ) | ||
|
|
||
| student_data = [ | ||
| ['Name of Student:', student_name, 'Roll No.:', student_info.get('rollNumber', student_info.get('roll_number', 'N/A'))], | ||
| ['Programme:', student_info.get('programme', 'N/A'), 'Branch:', student_info.get('branch', student_info.get('department', 'N/A'))], | ||
| ['Semester:', formatted_semester, 'Academic Year:', student_info.get('academicYear', student_info.get('academic_year', 'N/A'))] | ||
| [Paragraph('Name of Student:', cell_style), Paragraph(student_info.get('name', 'N/A'), cell_style), Paragraph('Roll No.:', cell_style), Paragraph(student_info.get('rollNumber', student_info.get('roll_number', 'N/A')), cell_style)], | ||
| [Paragraph('Programme:', cell_style), Paragraph(student_info.get('programme', 'N/A'), cell_style), Paragraph('Branch:', cell_style), Paragraph(student_info.get('branch', student_info.get('department', 'N/A')), cell_style)], | ||
| [Paragraph('Semester:', cell_style), Paragraph(formatted_semester, cell_style), Paragraph('Academic Year:', cell_style), Paragraph(student_info.get('academicYear', student_info.get('academic_year', 'N/A')), cell_style)] | ||
|
Comment on lines
+3549
to
+3551
|
||
| ] | ||
|
|
||
| student_table = Table(student_data, colWidths=[1.75*inch, 1.75*inch, 1.75*inch, 1.75*inch]) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
wordWrapparameter is not a standard parameter for ReportLab'sParagraphStyleclass. ReportLab's Paragraph class automatically handles word wrapping based on the available width without needing awordWrapparameter in the style definition. This parameter will likely be ignored, but could cause confusion or issues if the library behavior changes.Consider removing this line as word wrapping is automatically handled by the Paragraph class when it's constrained by the table column width.