From f4239760dfe3aaf5c150f28585c8780128f69d3a Mon Sep 17 00:00:00 2001 From: Thomas Reitz Date: Mon, 9 Mar 2026 20:27:32 +0100 Subject: [PATCH] fix: add PNG icons and Arial font to DOCX export Replaces text labels (Tel., Mobil, Mail, Adr.) with recolored PNG icons in the Word export contact section. Sets Arial as default document font to match Helvetica in the PDF export. Co-Authored-By: Claude Opus 4.6 --- .../expert-profile/profile-export.service.ts | 70 ++++++++++++------- 1 file changed, 46 insertions(+), 24 deletions(-) diff --git a/packages/core-service/src/core/expert-profile/profile-export.service.ts b/packages/core-service/src/core/expert-profile/profile-export.service.ts index af91087..f8c6675 100644 --- a/packages/core-service/src/core/expert-profile/profile-export.service.ts +++ b/packages/core-service/src/core/expert-profile/profile-export.service.ts @@ -512,37 +512,50 @@ export class ProfileExportService { // Kontakt-Sektion leftParagraphs.push(this.docxSectionHeading('KONTAKT', accentHex)); - const contactItems: Array<{ label: string; text: string }> = []; - if (data.phone) contactItems.push({ label: 'Tel.', text: data.phone }); - if (data.mobile) contactItems.push({ label: 'Mobil', text: data.mobile }); - if (data.email) contactItems.push({ label: 'Mail', text: data.email }); - for (const item of contactItems) { - leftParagraphs.push( - new Paragraph({ - children: [ - new TextRun({ text: `${item.label} `, bold: true, size: 14, color: accentHex }), - new TextRun({ text: item.text, size: 16, color: '555555' }), - ], - spacing: { after: 60 }, - }), - ); - } + // Icons für DOCX laden (eingefärbt in Akzentfarbe) + const docxPhoneIcon = this.loadIcon('Phone.png', accentColor); + const docxMobileIcon = this.loadIcon('Mobile.png', accentColor); + const docxMailIcon = this.loadIcon('Mail.png', accentColor); + const docxAddressIcon = this.loadIcon('Address.png', accentColor); + const docxIconSize = 12; - // Adresse separat (mit Zeilenumbruch) + if (data.phone) { + const children: (ImageRun | TextRun)[] = []; + if (docxPhoneIcon) { + children.push(new ImageRun({ data: docxPhoneIcon, transformation: { width: docxIconSize, height: docxIconSize }, type: 'png' })); + } + children.push(new TextRun({ text: ' ' + data.phone, size: 16, color: '555555' })); + leftParagraphs.push(new Paragraph({ children, spacing: { after: 60 } })); + } + if (data.mobile) { + const children: (ImageRun | TextRun)[] = []; + if (docxMobileIcon) { + children.push(new ImageRun({ data: docxMobileIcon, transformation: { width: docxIconSize, height: docxIconSize }, type: 'png' })); + } + children.push(new TextRun({ text: ' ' + data.mobile, size: 16, color: '555555' })); + leftParagraphs.push(new Paragraph({ children, spacing: { after: 60 } })); + } + if (data.email) { + const children: (ImageRun | TextRun)[] = []; + if (docxMailIcon) { + children.push(new ImageRun({ data: docxMailIcon, transformation: { width: docxIconSize, height: docxIconSize }, type: 'png' })); + } + children.push(new TextRun({ text: ' ' + data.email, size: 16, color: '555555' })); + leftParagraphs.push(new Paragraph({ children, spacing: { after: 60 } })); + } if (data.street || data.city) { - const addrRuns: TextRun[] = [ - new TextRun({ text: 'Adr. ', bold: true, size: 14, color: accentHex }), - ]; + const children: (ImageRun | TextRun)[] = []; + if (docxAddressIcon) { + children.push(new ImageRun({ data: docxAddressIcon, transformation: { width: docxIconSize, height: docxIconSize + 2 }, type: 'png' })); + } if (data.street) { - addrRuns.push(new TextRun({ text: data.street, size: 16, color: '555555' })); + children.push(new TextRun({ text: ' ' + data.street, size: 16, color: '555555' })); } const cityLine = [data.postalCode, data.city].filter(Boolean).join(' '); if (cityLine) { - addrRuns.push(new TextRun({ text: cityLine, size: 16, color: '555555', break: 1 })); + children.push(new TextRun({ text: ' ' + cityLine, size: 16, color: '555555', break: 1 })); } - leftParagraphs.push( - new Paragraph({ children: addrRuns, spacing: { after: 60 } }), - ); + leftParagraphs.push(new Paragraph({ children, spacing: { after: 60 } })); } // Sprachen @@ -725,6 +738,15 @@ export class ProfileExportService { // --- Dokument zusammenstellen --- const document = new Document({ + styles: { + default: { + document: { + run: { + font: 'Arial', + }, + }, + }, + }, sections: [ { properties: {