(element)
| 102 | } |
| 103 | |
| 104 | const renderComponent = async (element) => { |
| 105 | const source = await renderToBuffer(element) |
| 106 | |
| 107 | const document = await pdfjs.getDocument({ |
| 108 | data: source.buffer, |
| 109 | verbosity: 0 |
| 110 | }).promise |
| 111 | |
| 112 | const pages = range(document.numPages).map((pageIndex) => |
| 113 | document.getPage(pageIndex + 1) |
| 114 | ) |
| 115 | |
| 116 | if (pages.length === 1) { |
| 117 | return (await getCanvas(pages[0])).toBuffer() |
| 118 | } |
| 119 | |
| 120 | const canvases = await Promise.all( |
| 121 | pages.map((page) => getCanvas(page)) |
| 122 | ) |
| 123 | const pageSnapshots = composeCanvases(canvases) |
| 124 | |
| 125 | return pageSnapshots.toBuffer() |
| 126 | } |
| 127 | |
| 128 | export default renderComponent |
nothing calls this directly
no test coverage detected