galkahana / HummusJS

Node.js module for high performance creation, modification and parsing of PDF files and streams
http://www.pdfhummus.com
Other
1.14k stars 169 forks source link

Re-Save existing PDF in PDF/X-1a:2001 standard #323

Open hnitzsche opened 5 years ago

hnitzsche commented 5 years ago

First of all, I'm not sure if Hummus can do this, but to find it out I have to be a little off topic:

I have a big single page PDF file used for printing, that is being send to an Express server. My plan is to store the original file (this isn't the problem) and additionally some kind of web preview of the file (small PDF file size or low res png for example).

If I convert the PDF with gm/graphicsmagick to a png it misses some elements of the PDF after rendering. If I save the PDF in PDF/X-1a:2001 standard, it renders the file correctly.

So my question is, if it's possible to change the PDF standard on an existing PDF with Hummus. Or how I can manually change the relevant settings of the PDF like transparency etc.?

galkahana commented 5 years ago

yes and no.

hummus is too low level to provider you with a setting like "work with PDF/X-1a". however, it does provide you with methods to either create a PDF with content or modify existing content. so theoretically speaking you could implement "making a PDF PDF/X-1a compatible" using hummus and knowhow on what makes a PDF file PDF/X-1a compatible - specifically flatten all transparency.

but that's probably overwork.

maybe it's just a matter of finding out how to make gm process transparency correctly. see here some options: https://stackoverflow.com/questions/24686623/graphicsmagic-is-unable-to-identify-background-transparency-of-pdf