Label values are not showing on pdf

Good morning,

The labelling is not appearing on my form when I try to render it. I looked at the docs, and it seems that if you want to render the labelling ( self.label1.text) for example, you will need to pass it as argument for the rendering function, which I did but with no success. I have multiple forms and I imported the values from previous form (parent) onto the final form to generate my invoice.

when I view the form all the values from previous form appear just fine, and to clarify here : I used a global module with values passing from parent form to child form.

while if I try to generate a pdf all these values don’t show up on pdf but they appear at the form just fine.

what am missing here?

form before generating pdf

Hi @yahya and welcome to the forum,

When you’re rendering a form I’m not sure it has access to dynamic variables from global modules that were changed during the client session. (I might be wrong)

Imagine render form is creating a new instance of your app where the form being rendered is the startup form…

If this doesn’t help, perhaps you could provide a clone link as a minimal example demonstrating the problem

1 Like

As I understand it, render_form essentially starts up an independent, hidden Client session, behind the scenes, on an Anvil server. There’s no way it can share memory (variables) with a different instance running (perhaps) thousands of miles away in someone’s browser. Therefore, any variable values would have to be passed as explicit arguments.

2 Likes

@stucork @p.colbert much appreciate your feedback and help. Following your recommendations, I tried to pass argument to create_pdf function; however, I keep getting an error : 1 argument is missing from the function, which I passed but I don’t know why I am keep having this issue. i cloned a sample of the app here:https://anvil.works/build#clone:MIASIXLHEN2VP7RO=AIXNVWRSHCHM3LZ3IW5NXRLC

what are the possible ways of solving this issue or getting around it?

It looks like you were playing with render_form and open_form.

The line that is causing the error is from open_form where you’re not passing the required argument - name.

1 Like

Many thanks @stucork all sorted, i was just assigning the wrong reference, while running the rendering function

1 Like

A post was merged into an existing topic: Create PDF of embedded Form containing Data Grid/Repeating Panel