py-pdf / fpdf2

Simple PDF generation for Python
https://py-pdf.github.io/fpdf2/
GNU Lesser General Public License v3.0
1.05k stars 241 forks source link

New feature: generate PDF forms #257

Open Lucas-C opened 2 years ago

Lucas-C commented 2 years ago

The scope of this feature is to add support to fpdf2 to produce PDF forms.

More information about this PDF functionality & code samples can be found in section 12.7, "Interactive Forms", of the 1.7 PDF spec, as well as on the PDF Wikipedia page

By implementing this feature you, as a benevolent FLOSS developper, will provide access to the large community of fpdf2 users to a standard and useful PDF functionality. You will also be added into the contributors list & map. Moreover, by working on this feature, you will learn about PDFs encryption and the lifecycle & structure of a popular Python library.

As a contributor you will be free to design and craft this feature as you see best, while getting review feedbacks from maintainers & other contributors.

This issue can count as part of hacktoberfest

Lucas-C commented 2 years ago

Note that an /AcroForm field has been inserted in #468, to support document signing.

Lucas-C commented 2 years ago

Hi and welcome @Willy-Chan!

To be clear, the goal in this case is to create a function in fpdf2 that produces PDF forms?

Exactly!

I don't have a specific idea on the signature this method should have. This should be given some thought, given that PDF forms can be complex objects with many internal parts (form fields, appearence stream & layout, annotations & resource dictionary, optional JavaScript...). And the goal would be to expose those forms as a user-friendly, yet expressive, API. Of course the goal of this issue is just to implement a starting point, a MVP somehow, so that we can then add more features later on.

Sorry if I ask any dumb/newbie questions, english is not my first language and I'm really new to all this!

All questions are very welcome, don't worry! Just know that I may be slow to answer them, but please ask away! As a project maintainer, my goal is to assist contributions & contributors, I'd be more than happy to share the knowledge around this lib 😊 And I'm not a native english speaker neither ^^

fpdf2 is starting to have a code base with a significant size, it will takes some time to figure how things work internally (and the code structure/quality is far from perfect), added with the complexity of slowly understanding the PDF files internal structure/syntax. Arm yourself with a bit of patience, that's all I'm saying :D

Lucas-C commented 4 months ago

Note: PDF forms would allow to display collapsible areas with toggle buttons, like this sample PDF demonstrates: PDF_Buttons.pdf