gofpdf
gofpdf copied to clipboard
How to add editable cell?
I'd like to add some editable fields in my generated PDF with gofpdf. Make them editable in Safari or Chrome as the following screenshot. How can I do that?
I've already set protection:
pdf.SetProtection(gofpdf.CnProtectPrint|gofpdf.CnProtectCopy|gofpdf.CnProtectModify, "", "")
gofpdf does not currently support editable form fields. Fpdf (from which gofpdf is derived) has the following script: Form filling. Is that the kind of functionality you are after?
It's called AcroForms (a.k.a. Acrobat Forms) for PDF. I just found a browser-side JS lib which has a plugin for adding textfield/radio/button in PDF: https://github.com/MrRio/jsPDF/blob/master/plugins/acroform.js
Thanks, @lexrus, for the link. I'll label this issue as an enhancement and with luck find some time to work on it. If you're up to the task, it would make a great pull request!
Hello, and thank you for providing a useful tool for the go community!
Just curious if you have any plans to implement editable fields in gofpdf? It would be awesome to generate forms that can be filled out digitally rather than just when printed :)
thanks again!
I agree, this would be a very welcome enhancement. I have not had time to pursue this, but I continue to hope that someone will implement this.
I could attempt a PR with the feature, but I may need some guidance in where to start?
Thanks for your interest, @dhalman!
Rather than extending fpdf.go directly, the best approach is to create a new file that contains the extension logic. See layer.go as an example, and notice that it includes methods like layerPutCatalog and layerPutResourceDict to reduce the changes in fpdf.go to some method calls. You may need to add some fields to the Fpdf type; do this is def.go.
Most of the functionality in gofpdf is ported from the fpdf PHP package. It may be that editable field support can come from there as well. The form filling script may be a good start.
Once you get things working, one or more examples in fpdf_test.go provide test coverage and are a real help for people using your extension.
Good luck and don't hesitate to ask questions here along the way.