Python script such as pypdf to spawn a page from hidden template
I want to automate pre-filling of a PDF form, using data from an excel sheet. I can manage that part, but the hard part I am trying to do is that, if there is more than 1 row of data belonging to a single Company, I need to create an additional page for each row of data. (that is, all rows of data belonging to a single Company has to be on 1 PDF file, not 1 file each). However, that additional page I want to add is the Template page which I want to remain hidden.
So, is there any way for pypdf (or other packages) to automatically script and spawn from a hidden template page? If not, I am guessing the manual way would be to just pre-create the empty PDF file of 2 pages, 3 pages, etc, then in the script, detect how many rows needed and then access the corresponding PDF file with correct number of pages.
Oh, another important detail. For data processing reasons, I also strictly need the page to be added AS IF using the Adobe acrobat spawn method (https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#spawn) because I need the fields on each new page to have their Field Name to be correctly renamed with the page notation: P0.Fieldname, P1.Fieldname, P2.Fieldname, etc. This will be necessary for my data analysis script later on. I am not sure if there is a better way to do this, so currently these are the conditions I am working with.
i saw the pypdf documentation of the add page method but I am not too sure how it works and if it can add from a HIDDEN template page. https://pypdf.readthedocs.io/en/stable/_modules/pypdf/_writer.html#PdfWriter.add_page