How to create a pdf form using pdfrw using the pdf basics using the "/Annots" dictionary?

46 views Asked by At

I would like to create a pdf form button and other widgets in pdf using python but donot want to us the form generation modules available with pyupdf, borb etc..

I want to create a "Annot" pdf dictionary structure and add all the relevant details of the form button in to it. Request help from the team for a head start

1

There are 1 answers

1
Joris Schellekens On

disclaimer I am the author of borb

borb allows you to manipulate PDF documents both in a high-level and low-level fashion.

You can build forms by adding LayoutElement objects that inherit from FormField.

But you can just manipulate the underlying dictionaries of the PDF and do everything yourself. Or even do a combination of both.

Use an existing LayoutElement to already do most of the heavy lifting for you, and then tweak the final stuff yourself.

An example of doing everything yourself can be found here: https://github.com/jorisschellekens/borb-examples?tab=readme-ov-file#85-creating-a-document-using-low-level-syntax

Although this example doesn't go into detail about forms, it does show you how to manipulate the dictionaries that make up the PDF.

You can also find a copy of the PDF spec in the borb repository.