22 lines
757 B
TypeScript
22 lines
757 B
TypeScript
|
|
import * as React from "react";
|
||
|
|
import { Document, Page, View, Image, pdf } from "@react-pdf/renderer";
|
||
|
|
import fs from "fs";
|
||
|
|
|
||
|
|
async function main() {
|
||
|
|
const url = "https://pocketbase-gnqc88suy8fqk6wyryjjdpvl.169.239.180.130.sslip.io/api/files/pbc_1010367695/851t7163ks1f9qk/1u8lvckq51g_my2g8gttaf.jpg";
|
||
|
|
|
||
|
|
const inst = pdf(
|
||
|
|
<Document>
|
||
|
|
<Page size="A4" style={{ padding: 40, fontFamily: "Helvetica" }}>
|
||
|
|
<View>
|
||
|
|
<Image src={url} style={{ width: 110, height: 68 }} />
|
||
|
|
</View>
|
||
|
|
</Page>
|
||
|
|
</Document>
|
||
|
|
);
|
||
|
|
const buf = Buffer.from(await inst.toString(), "binary");
|
||
|
|
fs.writeFileSync("/tmp/debug-url.pdf", buf);
|
||
|
|
console.log("Size:", buf.length);
|
||
|
|
}
|
||
|
|
main().catch((e) => { console.error("FAIL", e); process.exit(1); });
|