Open haywoood opened 12 years ago
+1 Can anyone comment on how much work it would take to add this functionality? Thanks. great project.
+1 Would be a very useful feature
:+1:
+100 this would be invaluable
+1 Would love this, using Zend PDF (PHP) right now, but would love to do a rewrite in NodeJS, only feature lacking is loading an existing PDF. One thing that would make implementation easier, only support opening the older 1.4 format like Zend does, after 1.4 the format got more complex.
I wish we could put a bounty on this feature request. It's been reported as an issue 4 times(#101, #105, #168 ), and all four times it had strong interest.
IMHO this should be a separate library. This functionality would add significant code size requirements to PDFKit and not everyone needs it. It could use mozilla's pdf.js project to read the PDFs, and you'd need some sort of glue code to hook that into PDFKit somehow. I haven't looked into it enough to see exactly how it would work, but I think it is possible with a bit of effort. Unfortunately, it is not something I need, and I don't have time to work on it at the moment. However, if someone wants to take this on, I'm definitely available to help answer questions about the PDF format, PDFKit, etc.
@devongovett Good points. How about an optional add-on module rather than a completely separate library. Thanks for all you do.
If it helps it could be ported from https://github.com/hanneskod/fpdf which I'm currently using.
I would gladly pay a big bounty to be able populate "fields" with data from a collection within a pdf template. The template would have text, layout, and fields -- just fill in the fields with data. It seems no package does this at the moment. This seems to be something very common in the business world.
It looks like what I'm trying to do is called PDF form fill. It seems the pdftk command line tool can do this.
I have started working on a seperate library for editing PDFs, (http://github.com/ags131/pdfedit) it works by appending to the PDF file itself so that existing objects and their offsets remain the same.
Currently it is capable of adding pages and text, I plan on extending it out to generate PDF pages from a template. Technically, with this code, it should be possible to fairly easily fill Form values also, its just a matter of reading the right data structures and adjusting the values.
Its still highly WIP so please don't expect fully working and neat code in its current state
I originally planned on modifying pdfkit to where the data from a loaded PDF could be inserted, but my lack of coffeescript knowledge and pdfkit's assumption that its working from a clear state makes that much trickier.
@ags131 Fantastic!
@ags131 great, I'll check it out, if it does form fills and looks good, it's still not too late for me to switch to using it over PDFtk server.
@aadamsx Its still early WIP at the moment, but I'm developing it on out to hopefully replace the current Zend_PDF system I'm using for mass mailer generation. I'm about to look into form filling to see how complicated that part is.
:+1:
My use case is to append some text boxes on top of an existing document, annotate a pdf. Related to #227
:+1:
I am using HummusJS now. But it converts to native library.
I and my team were seriously hoping for PDFKit to be able to support modification.
I have also moved to HummusJS, its annoying having to use a native library, but allows editing existing. PDFs (Something my previous WIP library was designed for but was missing many features)
@pgAdmin @ags131 how are you adding images with hummus? (to existing pdfs)
@elgubenis https://github.com/galkahana/HummusJS/wiki/Show-images
pageContext.drawImage(10, 10, path_of_image , {index:2});
:+1:
This feature would also be huge for us. We really need to be able to add custom text to a PDF template that already exists.
We are running into this as well. My goal is not even to edit a PDF, just have page 1 and 2 be a cover sheet pdf, we do dynamic workon page 3, then have page 4 be static from existing pdf.
Sad to see this frature rewuest went nowhere. We have essentially dumped pdfkit due to this missing basic functionality.
+1000000 i needed this feature badly today, expected it was already built in... since it seems it's something you would expect right from the beginning. But that means I will have to find something else meanwhile :(
For those who are leaving this project for another. May I ask which project you are now using that allows you to edit PDFs? @NearlyNormal @rokyed
i am still searching @misbach, but i would have loved more to be able to use pdfkit for this
@misbach I will be using pdfrw and reportlab on python to handle this
To anyone who's run into this issue while looking for a way to edit PDF documents in NodeJS:
As of March 2019 I couldn't find a single feature-complete PDF library for NodeJS that lets me do everything I need. What I ended up doing is using PDFBox - this is an outstanding Java PDF library with all the features you can possibly need. I am using it to parse existing documents, populate form fields from JSON and insert images in pre-defined templates and form fields. I created a simple webservice that basically handles all the PDF-related work and the PDF-related code that I wrote is about 200-300 lines.
Just leaving this here for 2 reasons:
@radoslavpetranov have you tried HummusJS https://github.com/galkahana/HummusJS ?
pdf-lib just published v1.0 https://github.com/Hopding/pdf-lib. It has all the basic features you would need for pdf generation and pdf manipulation but lacks a lot of the niceties that pdfkit provides such as line wrapping, lists, stroke, etc. and their documentation is pretty bare bones. Currently planning to use pdfkit to create pdf's from scratch and then import into pdf-lib to form fill existing pdf's. https://github.com/Hopding/pdf-lib/issues/9
It would be wonderful to just use one library to do this and pdfkit has a huge leg up on pdf-lib. Given enough time, pdf-lib will likely replace pdfkit entirely if they keep up what they're doing because of existing pdf modification.
Crazy to get a notification on this issue, what feels like a world away when I opened it. I was just starting to program back then 😂
For context of use, I worked for a company that had to add a lot of text to HP brochures, and we were looking to possibly automate that by templatizing the designs.
+1 I need to edit 120 pdf files to change one word (😪), and i thought that would be nice if we have a feature to edit and replace texxt
👍
My use case is to append some text boxes on top of an existing document, annotate a pdf. Related to #227
giao
I just stumbled upon, https://itextpdf.com/en/blog/itext-news/introducing-itext-dito-powerful-template-engine-converts-data-itext-quality-pdfs This is unfortunately in java and is paid. Would love to see if pdf kit can do something like this. Given the scope and usefulness of this i think putting a bounty on this is pretty much reasonable :-)
Eventhough the issue title is "Edit existing PDF" i think the core problem is having a templating system which both designers and developers can use
I have a brochure that is in pdf form, and want to make parts of the text dynamic. Is there currently a way to do something like this?