From d6876f6107fbffde2cb6197e7bd14f5da2cb916b Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Tue, 9 Jun 2026 15:55:10 +0200 Subject: [PATCH] chore: clean up output to only generate one print PDF per person - Script no longer leaves RGB masters or spaces in filenames --- scripts/generate-business-cards.ts | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/scripts/generate-business-cards.ts b/scripts/generate-business-cards.ts index 8a1e915b..51fd6ff6 100644 --- a/scripts/generate-business-cards.ts +++ b/scripts/generate-business-cards.ts @@ -76,28 +76,27 @@ END:VCARD`; }); const safeName = person.name.replace(/\s+/g, '_'); - const rgbFileName = `KLZ_BusinessCard_${safeName}_RGB.pdf`; - const cmykFileName = `KLZ_BusinessCard_${safeName}_CMYK_Print.pdf`; - - const rgbPath = path.join(CONFIG.outputDir, rgbFileName); - const cmykPath = path.join(CONFIG.outputDir, cmykFileName); + const finalFileName = `KLZ_Visitenkarte_${safeName}.pdf`; + const tempRgbPath = path.join(CONFIG.outputDir, `temp_rgb_${safeName}.pdf`); + const finalPath = path.join(CONFIG.outputDir, finalFileName); console.log(`- Rendering React-PDF layout...`); const buffer = await renderToBuffer( React.createElement(PDFBusinessCard, { person, - logoWhitePath: CONFIG.logoWhite, - logoBluePath: CONFIG.logoBlue, - logoFullPath: CONFIG.logoFull, - truckImagePath: CONFIG.truckImage, qrCodeDataUrl, }), ); - fs.writeFileSync(rgbPath, buffer); - console.log(`✓ RGB Master generated: ${rgbFileName}`); + fs.writeFileSync(tempRgbPath, buffer); + convertToCMYK(tempRgbPath, finalPath); - convertToCMYK(rgbPath, cmykPath); + // Clean up temporary RGB file + if (fs.existsSync(tempRgbPath)) { + fs.unlinkSync(tempRgbPath); + } + + console.log(`✓ Final Print File generated: ${finalFileName}`); } }