There should be support for local filepath when using src attribute of the Image component. Althouth it seems very simple to do I didn't go straight to a PR because the core package is shared between node and the browser, so directly using node packages such as path and fs might not be an option as far as I understand.
We could go with something like:
// pseudo code
if (src.startsWith('file://')) {
const fs = require('fs')
return fs.read(src)
}
@diegomura what are your thoughts ?
Thanks @theobat !
You are right about we must have support for this feature.
Luckily for us, pdfkit already has support for local image files, so there is less to do on our side (http://pdfkit.org/docs/images.html).
I would avoid the file:// prefix and just stick with urls and paths. If it's a url we fetch the image and add it to the doc (using http as the default protocol if not specified), and if it's a path, we pass the path to pdfkit and let him read it from the file system. What do you think? Would you like to upload a PR with this feature? That would be great
All right I'm gonna do this
Any updates on this?
Most helpful comment
All right I'm gonna do this