SVG Report Renderer
Pure Swift SVG generator for reports using Core Text for text measurement.
API
public enum SVGReportRenderer {
// Synchronous render without images
public static func render(_ data: ReportData) -> String
// Async render with image embedding
public static func render(
_ data: ReportData,
imageProvider: ReportImageProvider
) async -> String
} ReportImageProvider Protocol
For lazy loading record images into the report.
public protocol ReportImageProvider: Sendable {
func loadImageData(filename: String, for recordId: UUID) async -> Data?
} Page Dimensions
- A4 Landscape: 842 x 595 points (72 DPI)
- Margins: 40 points
Layout Sections
- Header (~60pt): Title, date range, total hours
- Stacked Bar Chart (~200pt): See 308-stacked-chart
- Comments Section (~300pt): See 309-comments-section
- Footer (25pt): “Generated by MINUTA.tools”
Text Measurement
Uses Core Text for accurate text width calculation:
- Font: System font at specified size
- Measures actual rendered width for layout
Text Wrapping
Comments are wrapped to fit column width:
- Uses Core Text for measurement
- 4-line maximum with ”…” truncation
- Proper word boundary handling
Related
- 306-report - Report data models
- 308-stacked-chart - Chart rendering details
- 309-comments-section - Comments layout
- 310-webkit-service - PDF/PNG conversion