Anvil.pdf No attribute PdfRenderer

Hi Anvil Team,

I’m loving the new PDF functionality so far. I did my testing of it via a Jupyter Notebook and the anvil uplink feature. The following two lines would generate my pdf file as expected and save it to my computer.

pdf = anvil.pdf.PdfRenderer(scale=0.75, page_size='Letter').render_form("OrderReview",order_id=2001070)

anvil.media.write_to_file(pdf, "OrderReview.pdf")

When I try to use this line on the server, I receive the following error message.

pdf = anvil.pdf.PdfRenderer(scale=0.75, page_size='Letter').render_form("OrderReview",order_id=2001070)

AttributeError: module ‘anvil.pdf’ has no attribute ‘PdfRenderer’

Why is the anvil.pdf module acting differently on the server? How do I get to the PdfRenderer function there?

Thank you!

1 Like

Hi there. The following works for me:

from anvil.pdf import PDFRenderer

Could it be a spelling issue?

I’m just using “import anvil.pdf” in both places (on the anvil server and via my uplink). I’ll test out some variations shortly on the server side.

Yes, that is totally fine in terms of importing. I believe that the issue is the capitalization. Try using PDFRenderer (i.e., with the correct letter case).

You’re correct! I’m not sure why that didn’t blow up locally though. Either way, thank you for the tip!

Excellent Solution… Would have taken me days to figure this out…