import * as React from "react"; import { Document, Page, View, Image, pdf } from "@react-pdf/renderer"; import fs from "fs"; async function main() { // Read a real JPEG const buf = fs.readFileSync("/tmp/debug-logo.bin"); console.log("Input bytes:", buf.length); console.log("First bytes:", buf.slice(0, 4).toString("hex")); // Try to use it directly as Image src const inst = pdf( ); const out = Buffer.from(await inst.toString(), "binary"); fs.writeFileSync("/tmp/raw-buf-test.pdf", out); console.log("PDF size:", out.length); // Check the image bytes const idx = out.find(Buffer.from("stream\n")); if (idx >= 0) { console.log("Stream at:", idx); console.log("First 20 bytes after stream:", out.subarray(idx+7, idx+27).toString("hex")); } } main().catch(e => { console.error("FAIL:", e); process.exit(1); });