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