* Get or create a synthetic PDF cached to disk.
(path: string, pageCount: number)
| 122 | * Get or create a synthetic PDF cached to disk. |
| 123 | */ |
| 124 | async function getOrCreateSynthetic(path: string, pageCount: number): Promise<Uint8Array> { |
| 125 | if (existsSync(path)) { |
| 126 | return loadFixture(path); |
| 127 | } |
| 128 | |
| 129 | console.log(`Building synthetic ${pageCount}-page PDF...`); |
| 130 | const start = performance.now(); |
| 131 | |
| 132 | const bytes = await buildSyntheticPdf(pageCount); |
| 133 | |
| 134 | mkdirSync(SYNTHETIC_DIR, { recursive: true }); |
| 135 | writeFileSync(path, bytes); |
| 136 | |
| 137 | const elapsed = ((performance.now() - start) / 1000).toFixed(1); |
| 138 | const size = (bytes.length / 1024 / 1024).toFixed(1); |
| 139 | |
| 140 | console.log(`Cached ${pageCount}-page PDF to ${path} (${size}MB) in ${elapsed}s`); |
| 141 | |
| 142 | return bytes; |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * Get a synthetic 100-page PDF. |
no test coverage detected