Create PDF of embedded Form containing Data Grid/Repeating Panel

I have a multi-form app where the startup form “Home” provides navigation and all subsequent forms exist within its content_panel.

Home
-Form1
-Form2
-etc

Each of these forms that get displayed eventually in Home’s content_panel contain data grid/ repeating panels of information. These all display to screen properly.

However, I can’t figure out how to make a button/link that will generate a PDF with the contents of Form1, Form2, etc that are being sent to screen. Specifically, the data that is displayed in the Data Grid / Repeating Panels on the screen doesn’t populate to the PDF that is created.

In looking at the basic render_form function described in Generating PDFs with Python and Anvil, that example of building out a ticket seems to describe the creation of the pdf within the process of passing data to populate the form (ie the “ticket”) you want to generate. How would one create a PDF of a form containing data grid / repeating panels AFTER the data has already populated the repeating panels? I’m looking for a way to simply dump everything showing on the screen for Form1, Form2, etc into PDFs.

Thank you.

Awakening the dead here…

So how would one ever use render_form to generate a pdf when a form’s content is contingent upon variables created in the original client session? For example, I have an app where database lookups are populating a data grid based upon the user’s id, role within our school, campus, etc that are all inherently dependent upon the original client session. I’m completely stuck on getting my teachers to generate pdfs of their data populating a data grid. It shows up on screen just fine, I just can’t get the of that web browser session.

Thanks.

The docs on using the built in PDF rendering seems pretty clear: Anvil Docs | Creating PDFs

Your form must take arguments to its init function and populate the UI based on those arguments. Then you can pass those arguments to render_form.

This would suggest that you have a form that’s designed to be the PDF form, and another form that’s designed to be the interactive one. You can share an embedded component between those two if you want the UI to be the same between them.

1 Like

The docs on using the built in PDF rendering seems pretty clear

I would agree with that up to the point that I didn’t see in the documentation that the render_form() server call doesn’t get access to any kind of my_globals modules that exist. I had to go digging through old forum posts to finally see that was in play.

The tension in the documentation is that it’s simplistically written to handle the most basic use cases, but the understanding of how that render_form() server call relates to one’s global modules isn’t something a novice is necessarily going to intuit. Hence, this basic example documentation leans on non-basic understanding of the anvil platform that isn’t provided up front.

If you have suggestions on additions to the documentation, there’s an ongoing thread where those can be added as you run across them: Anvil Documentation Suggestions [ON-GOING]

1 Like

That’s a great reference. Thanks for sending it along.