Open stevebaldwin21 opened 5 years ago
this would be a trivial example using PDFRStreamForFile, with a jpg file:
var stream= new hummus.PDFRStreamForFile('/path/to/my/jpg/file');
pdfWriter.createFormXObjectFromJPG(stream);
but sounds like the syntax is quite clear to you.
what's not clear is whether node-canvas can be used in PDFRStreamForBuffer. so here's a little test for you. PDFRStreamForBuffer is a custom stream, and as such implements this. use read
and notEnded
to read the image and write the result to a file...then see if you got a jpeg.
you probably wont, and then you just have to figure out why this part is not working.
either node-canvas stream cant be used together with PDFRStreamForBuffer,and you'll have to find, or write you own Custom Stream wrapper, or you'll find something surprising.
Gal.
Hey @galkahana
Thanks for your fast response. I'll check try your example. {node-canvas}.toBuffer method returns a buffer which should be compatible with PDFRStreamForBuffer (in that it implements the byteLength).
Off topic; your dog is hella cute and great work on the repo!!!
@stevebaldwin21 did you get the buffer mechanism to work? If so, could you share your example? thanks.
From the docs linked above it seems you can use image streams. However after looking at the source it seems that the drawImage function requires a string argument for filename.
Can someone confirm this? Am I making a mistake?
It seems like it.
Look at the example provided on the wiki here
@shaehn
Sorry!
I never managed to get this working in the way I would like. I instead decided to use a different solution. (I can't however say as its private code for my work), I can vouch this is a great library however and hope to see this in the future!
I am trying to pass a stream from node-canvas with the PDFRStreamForBuffer class into this method and getting the error of;
TypeError: unable to create form xobject. verify that the target is an existing jpg file/stream
Could you please give an example of how to use this method with the stream instance.
Thanks