fix: apply numbered list normalization to all PDF text blocks including nested fields

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
admin
2026-02-25 12:26:46 -05:00
parent 6c9ee877c9
commit 7ed9571cb9

View File

@@ -843,19 +843,25 @@ class PDFGenerationService {
doc.moveDown(0.5); doc.moveDown(0.5);
// Add section content // Add section content
const renderText = (label: string, val: string) => {
const normalized = val.replace(/\.\s+(\d+)\)\s/g, '.\n$1) ');
doc.fontSize(10).font('Helvetica-Bold').text(`${label}:`);
doc.fontSize(10).font('Helvetica').text(normalized, { lineGap: 2 });
doc.moveDown(0.3);
};
Object.entries(section.data).forEach(([key, value]) => { Object.entries(section.data).forEach(([key, value]) => {
if (value && typeof value !== 'object') { if (value && typeof value === 'object' && !Array.isArray(value)) {
// Normalize inline numbered lists to newline-separated // Nested object — render sub-fields
const normalizedValue = String(value).replace(/\.\s+(\d+)\)\s/g, '.\n$1) '); doc.fontSize(11).font('Helvetica-Bold').text(this.formatFieldName(key));
doc.fontSize(10) doc.moveDown(0.2);
.font('Helvetica-Bold') Object.entries(value as Record<string, unknown>).forEach(([subKey, subVal]) => {
.text(`${this.formatFieldName(key)}:`); if (subVal && typeof subVal !== 'object') {
renderText(` ${this.formatFieldName(subKey)}`, String(subVal));
doc.fontSize(10) }
.font('Helvetica') });
.text(normalizedValue, { lineGap: 2 }); } else if (value && typeof value !== 'object') {
renderText(this.formatFieldName(key), String(value));
doc.moveDown(0.3);
} }
}); });