![]() So i changed it, and added image.alphaLayer = smaskimg I don't know if someone has encountered this error before ? The problem is now that the image doesn't load completely, as if the smask and the image itself had different dimensions. When saving the png files, I noticed that the alphaLayer used is the image itself and not the real alphaLayer that we get Hi, I tried the solution of this comment : So it'll be awhile before this feature lands in pdf-lib. However, unless somebody from the community decides to work on this, there are several other things I have to work on first. I imagine it would be quite useful to many developers. I think that adding proper support for image extraction would be an interesting feature to implement in pdf-lib. But full support doesn't yet seem available. It looks like this may be possible for certain types of images: mozilla/pdf.js#7813 mozilla/pdf.js#7043. I did a bit of googling to see if pdf.js has an API to extract images from PDFs. It could certainly be improved by porting some code from pdf.js. The script will extract as many embedded images as it can from the PDF into the images/ directory.Īgain, this does not extract all possible types of images. You just need to unzip the file and run yarn install (or npm install) and then run node index.js existing1.pdf or node index.js existing2.pdf. This is because the embedded image format outlined in the PDF specification is pretty long and complicated (as are many things in PDF files).Īll of that being said, I created a script that extracts the more common image formats from PDF files. All of this logic would need to be ported over to use pdf-lib in order to handle all possible types of images. In particular, it's PDFImage class is worth looking at. This makes it a very good reference to see how this might be done using pdf-lib. So, of course, this library must be able to extract and render all types of images. Pdf.js is an open source PDF rendering engine maintained by Mozilla. It turns out, you'll have to write a fair amount of code if you want to handle all possible images in any type of PDF file. The question is, how much code will you have to write on top of pdf-lib to do this. Hello I've finally gotten some time to finish up my investigation into this.įirst off, it is possible to extract all image types from a PDF using pdf-lib.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |