MCPcopy
hub / github.com/diegomura/react-pdf / renderToFile

Function renderToFile

packages/renderer/src/node/renderToFile.js:5–19  ·  view source on GitHub ↗
(element, filePath, callback)

Source from the content-addressed store, hash-verified

3import { pdf } from '../index';
4
5export const renderToFile = async (element, filePath, callback) => {
6 const instance = pdf(element);
7 const output = await instance.toBuffer();
8 const stream = fs.createWriteStream(filePath);
9
10 output.pipe(stream);
11
12 return new Promise((resolve, reject) => {
13 stream.on('finish', () => {
14 if (callback) callback(output, filePath);
15 resolve(output);
16 });
17 stream.on('error', reject);
18 });
19};
20
21export default renderToFile;

Callers

nothing calls this directly

Calls 2

pdfFunction · 0.90
resolveFunction · 0.85

Tested by

no test coverage detected