Files
klz-cables.com/lib/pdf-business-card.tsx
Marc Mintel 1f07999d48
All checks were successful
Build & Deploy / 🔍 Prepare (push) Successful in 8s
Build & Deploy / 🧪 QA (push) Successful in 53s
Build & Deploy / 🏗️ Build (push) Successful in 1m59s
Build & Deploy / 🚀 Deploy (push) Successful in 14s
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 1s
fix: match customer draft layout and correctly use PNG assets for QR Code and Logos
2026-06-09 11:23:44 +02:00

203 lines
4.7 KiB
TypeScript

import React from 'react';
import { Document, Page, Text, View, StyleSheet, Font, Image } from '@react-pdf/renderer';
export interface PersonData {
name: string;
role: string;
phone: string;
email: string;
}
interface PDFBusinessCardProps {
person: PersonData;
logoWhitePath: string;
logoBluePath: string;
logoFullPath: string;
truckImagePath: string;
qrCodeDataUrl: string;
}
const styles = StyleSheet.create({
page: {
width: '85mm',
height: '55mm',
backgroundColor: '#ffffff',
position: 'relative',
fontFamily: 'Helvetica',
},
pageBleed: {
// 85x55mm + 3mm bleed on each side = 91x61mm
width: '91mm',
height: '61mm',
backgroundColor: '#ffffff',
position: 'relative',
fontFamily: 'Helvetica',
overflow: 'hidden',
},
// FRONT PAGE
frontContainer: {
flex: 1,
position: 'relative',
padding: '8mm',
},
frontLogo: {
position: 'absolute',
top: '5mm',
right: '5mm',
width: '25mm',
},
truckImage: {
position: 'absolute',
bottom: '-2mm',
left: '-5mm',
width: '100mm', // cover bleed width
height: '50mm',
objectFit: 'contain',
},
// BACK PAGE
backContainer: {
flex: 1,
position: 'relative',
padding: '6mm 6mm',
},
backLogo: {
width: '20mm',
marginBottom: '8mm',
},
backMiddle: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
marginBottom: '8mm',
},
nameSection: {
flexDirection: 'column',
width: '35%',
},
nameText: {
fontSize: 16,
fontWeight: 700,
color: '#000000',
marginBottom: 2,
},
roleText: {
fontSize: 8,
fontWeight: 400,
color: '#333333',
},
contactSection: {
flexDirection: 'column',
width: '45%',
paddingLeft: '2mm',
},
contactRow: {
flexDirection: 'row',
alignItems: 'center',
marginBottom: 3,
},
iconCircle: {
width: 12,
height: 12,
borderRadius: 6,
backgroundColor: '#82ed20',
justifyContent: 'center',
alignItems: 'center',
marginRight: 4,
},
contactText: {
fontSize: 6.5,
fontWeight: 500,
color: '#000000',
},
qrSection: {
width: '20%',
alignItems: 'flex-end',
},
qrCode: {
width: '18mm',
height: '18mm',
},
footer: {
position: 'absolute',
bottom: '5mm',
left: '6mm',
right: '6mm',
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
},
footerText: {
fontSize: 6.5,
fontWeight: 500,
color: '#000000',
},
pipe: {
fontSize: 6.5,
fontWeight: 500,
color: '#82ed20',
marginHorizontal: 3,
},
});
export const PDFBusinessCard: React.FC<PDFBusinessCardProps> = ({
person,
logoFullPath,
truckImagePath,
qrCodeDataUrl,
}) => {
return (
<Document
title={`Business Card - ${person.name}`}
author="KLZ Cables"
creator="KLZ React-PDF Engine"
>
{/* FRONT - 91x61mm with Bleed */}
<Page size={[258, 173]} style={styles.pageBleed}>
<Image src={truckImagePath} style={styles.truckImage} />
<Image src={logoFullPath} style={styles.frontLogo} />
</Page>
{/* BACK - 91x61mm with Bleed */}
<Page size={[258, 173]} style={styles.pageBleed}>
<View style={styles.backContainer}>
<Image src={logoFullPath} style={styles.backLogo} />
<View style={styles.backMiddle}>
<View style={styles.nameSection}>
<Text style={styles.nameText}>{person.name}</Text>
<Text style={styles.roleText}>{person.role}</Text>
</View>
<View style={styles.contactSection}>
<View style={styles.contactRow}>
<View style={styles.iconCircle} />
<Text style={styles.contactText}>{person.phone}</Text>
</View>
<View style={styles.contactRow}>
<View style={styles.iconCircle} />
<Text style={styles.contactText}>{person.email}</Text>
</View>
<View style={styles.contactRow}>
<View style={styles.iconCircle} />
<Text style={styles.contactText}>klz-cables.com</Text>
</View>
</View>
<View style={styles.qrSection}>
<Image src={qrCodeDataUrl} style={styles.qrCode} />
</View>
</View>
<View style={styles.footer}>
<Text style={styles.footerText}>KLZ Vertriebs GmbH</Text>
<Text style={styles.pipe}>|</Text>
<Text style={styles.footerText}>Raiffeisenstraße 22</Text>
<Text style={styles.pipe}>|</Text>
<Text style={styles.footerText}>73630 Remshalden</Text>
</View>
</View>
</Page>
</Document>
);
};