Rework generation page and settings
This commit is contained in:
96
src/lib/pdfSettings.ts
Normal file
96
src/lib/pdfSettings.ts
Normal file
@@ -0,0 +1,96 @@
|
||||
// User-configurable settings for PDF generation
|
||||
|
||||
export interface PageSettings {
|
||||
pageWidth: number; // mm
|
||||
pageHeight: number; // mm
|
||||
margin: number; // mm
|
||||
}
|
||||
|
||||
export interface CardDimensions {
|
||||
width: number; // mm
|
||||
height: number; // mm
|
||||
}
|
||||
|
||||
// A4 Page dimensions in millimeters
|
||||
export const PAGE_SETTINGS: PageSettings = {
|
||||
pageWidth: 210,
|
||||
pageHeight: 297,
|
||||
margin: 10
|
||||
};
|
||||
|
||||
// Dimensions for a single card in the text PDF.
|
||||
// These dimensions will be used to calculate how many cards can fit on a page.
|
||||
export const TEXT_CARD_DIMENSIONS: CardDimensions = {
|
||||
width: 63,
|
||||
height: 40
|
||||
};
|
||||
|
||||
// Dimensions for a single card in the photo PDF.
|
||||
export const PHOTO_CARD_DIMENSIONS: CardDimensions = {
|
||||
width: 25,
|
||||
height: 35
|
||||
};
|
||||
|
||||
// Photo dimensions within the photo card
|
||||
export const PHOTO_DIMENSIONS = {
|
||||
width: 20, // mm
|
||||
height: 35 // mm
|
||||
};
|
||||
|
||||
export interface TextPosition {
|
||||
x: number; // mm, relative to cell top-left
|
||||
y: number; // mm, relative to cell top-left
|
||||
size: number; // font size in points
|
||||
}
|
||||
|
||||
export interface PhotoPosition {
|
||||
x: number; // mm, relative to cell top-left
|
||||
y: number; // mm, relative to cell top-left
|
||||
width: number; // mm
|
||||
height: number; // mm
|
||||
}
|
||||
|
||||
export interface TextFieldLayout {
|
||||
name: TextPosition;
|
||||
nationality: TextPosition;
|
||||
birthday: TextPosition;
|
||||
}
|
||||
|
||||
export interface PhotoFieldLayout {
|
||||
photo: PhotoPosition;
|
||||
name: TextPosition;
|
||||
}
|
||||
|
||||
// Text PDF Field Positions (in mm, relative to cell top-left)
|
||||
export const TEXT_FIELD_LAYOUT: TextFieldLayout = {
|
||||
name: {
|
||||
x: 2,
|
||||
y: 5,
|
||||
size: 10 // font size in points
|
||||
},
|
||||
nationality: {
|
||||
x: 2,
|
||||
y: 10,
|
||||
size: 10
|
||||
},
|
||||
birthday: {
|
||||
x: 2,
|
||||
y: 15,
|
||||
size: 10
|
||||
}
|
||||
};
|
||||
|
||||
// Photo PDF Field Positions (in mm, relative to cell top-left)
|
||||
export const PHOTO_FIELD_LAYOUT: PhotoFieldLayout = {
|
||||
photo: {
|
||||
x: 2, // 2mm from left of cell
|
||||
y: 2, // 2mm from top of cell
|
||||
width: PHOTO_DIMENSIONS.width,
|
||||
height: PHOTO_DIMENSIONS.height
|
||||
},
|
||||
name: {
|
||||
x: 2, // 2mm from left of cell
|
||||
y: PHOTO_DIMENSIONS.height + 0, // Below the photo + 5mm gap
|
||||
size: 5 // font size in points
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user