Repeating panel for a pdf

I have this repeating panel that displays the search between certain dates or of specific items bewteen dates selected by the user, I need to produce a pdf, but I dont really understand server modules or what part of the search function can I put on the module so I can call it like some users has done to tell the render form to take only the results of the table for the pfd and not the rest of the form, how should I approach this?

I generated the PDF but the results werent show on the pdf, it looked like the form without the results in the repeating panel

this is the only thing on the server module that I have writen:

import anvil.pdf

def reporte_pdf():
  media_object = anvil.pdf.render_form('registro_listocar.registro_listocar_reporte')
  return media_object

and the button that does the search between dates and a text parameter has this:

def button_busq_placayfecha_click(self, **event_args):
    start_date =
    end_date =
    busq_placa = self.search_placa_box.text
    queries = [q.none_of()]
    if start_date:
    if end_date:
    if busq_placa:
    self.repeating_panel_reporte.items =*queries))

my button for the pdf has this:

def b_emrep_listocar_click(self, **event_args):
    media_object ='reporte_pdf', self.repeating_panel_reporte.items)

if you wish to check the app:

When you render a form to a PDF you are not getting an existing instance of the form. You are getting a brand new instance of the form. Your button on the form will never be pressed, because the instance is never shown to the user, just used to generate the PDF.

You must pass any data into the __init__ of the form and populate any components there.

Due to PDF rendering timeout issues, you should collect all the data needed before trying to render the PDF (e.g. in a dictionary) and pass the data to the form so it can populate itself.

1 Like

Im not sure where my items for my repeating panel are being stored, if they are, of my search and how should I store the search on a dictionary.

A list can work the same as the dictionary? I read that dictionary dont allow duplicates, but my table will be registering the same vehicle multiple times diferent dates and with diferent services, and a list can also be used.

You don’t need to store your repeating panel items anywhere. You should pass the information needed to the server function (contents of the text boxes and date pickers, etc). On the server, you do the queries to get the items the form would have put into the repeating panel. You then pass those items to the PDF generator so it gets passed to the form’s __init__ function.

You can pass whatever you want to the init function. If your PDF form only needs a list, then pass a list. If your form needs more than just the list, pass a dictionary. The dictionary can contain a list.

1 Like