WFDASH-WEBAPP/scripts/dev/debug-png-workarounds.tsx
SJCoetz 714e910949 feat: add branded quote PDF generation and in-app viewer
This commit adds full quote PDF generation functionality with per-company letterhead branding:
- Server-side PDF rendering using @react-pdf/renderer matching the sample quote layout
- In-app modal PDF viewer with print, download, and new-tab controls
- Letterhead service to fetch and apply company-specific branding (CNL/ISHERWOOD)
- ZAR currency and date formatting utilities for South African quotes
- Updated QuoteAttachment type to handle PocketBase's array-based file tokens
- Fixed PocketBase attachment URL generation in quote email card
- Removed deprecated `included_in_quote` field from QuoteItem and quotes service
- Updated quote item creation test to validate draft item logic
- Added comprehensive unit tests for PDF rendering and formatting helpers
- Added dev scripts for debugging PDF and image rendering issues
- Added sample generated PDF files for visual verification
- Updated tsconfig to exclude development scripts directory
- Added @react-pdf/renderer production dependency
- Removed JEI as a valid letterhead option per requirements
2026-06-23 08:30:38 +02:00

38 lines
No EOL
1.5 KiB
TypeScript

/* eslint-disable */
import * as React from "react";
import { Document, Page, Image, ImageBackground, View, pdf } from "@react-pdf/renderer";
import fs from "fs";
async function main() {
const buf = fs.readFileSync("/tmp/debug-logo.png");
console.log("=== Test 1: Image (default) ===");
const inst1 = pdf(
<Document><Page size="A4" style={{padding: 40}}>
<Image src={buf} style={{ width: 110, height: 68 }} debug />
</Page></Document>
);
const out1 = Buffer.from(await inst1.toString(), "binary");
console.log(" size:", out1.length);
console.log("=== Test 2: ImageBackground (no debug) ===");
const inst2 = pdf(
<Document><Page size="A4" style={{padding: 40}}>
<ImageBackground src={buf} style={{ width: 110, height: 68 }} />
</Page></Document>
);
const out2 = Buffer.from(await inst2.toString(), "binary");
console.log(" size:", out2.length);
console.log("=== Test 3: SVG with embedded JPEG base64 ===");
const b64 = buf.toString("base64");
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="110" height="68" viewBox="0 0 323 200"><image href="data:image/png;base64,${b64}" width="323" height="200"/></svg>`;
const inst3 = pdf(
<Document><Page size="A4" style={{padding: 40}}>
<Image src={svg} style={{ width: 110, height: 68 }} />
</Page></Document>
);
const out3 = Buffer.from(await inst3.toString(), "binary");
console.log(" size:", out3.length);
}
main().catch(e => { console.error("FAIL:", e); process.exit(1); });