Fast PDF - a new way do do PDF's in Anvil

I thrilled to introduce a new high performance PDF framework.

Whats wrong with Anvils build in PDF system?
Nothing - its great but for our use cases it was not the optimal fit.

Whats Fast PDF?
Its an Anvil specific pdf and template libary that allows you to build high quality and high performance pdf file.

  1. Generate PDF’s client side without the need for a server round trip. → Instant PDF’s even offline
  2. Define pdf’s as code templates to have fine grained control over each pdf part. → Exact Look and Feel
  3. High performance rendering, easily create thousands of pages in fractions of seconds. → Speed
  4. Build in PDF helpers for printing, previewing and so on. → Usability.

How to use it?
Use the dependency with the key: NRVII2QKUF7NSGEP

Simple Example Code:

  doc = fast_pdf.Document()
  doc.cell(20,4,'Hello World')

For more advanced use cases check the examples app:

Live Preview:

Side Note
If you only ever generate PDFs on the server, its proboably better to just stick to fpdf or something like that. Fast PDF is interesting if you need to also create pdf’s client side.

How does it work?
Its basically just a wrapper around jspdf and fpdf2 with a common interface and a bunch of helper function in regards to anvil. Depending on where you render the pdf client or server it will build your template with the library for the respective plattform.


So far, looks great! Will definitely love to test it on my apps.

is the “key” “NRVII2QKUF7NSGEP”. correct , i got a permission error loading dependency

Never mind , worked on 2nd try …

I cloned your example, but for me it does seem NOT to work. I have the following message:
Screenshot 2023-07-07 16.11.31
and if I click RUN, I get : Cannot read properties of undefined (reading ‘expires_at’)

Strange - seems more of an Anvil issue to me but I updated the clone example link without the dependencies.

Maybe try again with the new link. :+1:

This looks like an excellent piece of work!

Would you consider releasing this under an open source licence?

I have a project where it might be very useful but we wouldn’t consider using a dependency where we can’t see the code and don’t know what the licence terms would be.

(Also, anyone on an enterprise licence can’t use a third party dependency anyway).

Hi @owen.campbell,

Sure - I used anvil-extras free of charge for long enough.

I pushed the code to a public git repo with MIT licence.

Here is the original Dependency as an Anvil clone link.

Two more things:

  1. The latest release v0.7 is stable and we use it ourselfs in production. It is however possible that a pdf rendered server side can look slightly different from the client version in some edge cases.

  2. Single source of truth will remain the anvil repo for now. Because we would first need to incorporate the git action that pushes to anvil in our release pipeline. And I’ll need some time & reason to prepare and communicate that.

But all in all this should get you started :+1:


Excellent! Thank you kindly.

1 Like

Thank you Mark,
I will check it out soon. Love to have that on client side.
Cheers Aaron

1 Like

Thank you very much Mark

And how we construct PDF file?
We have sample PDF files but what is the rules?
Do you have some Guide ?

For 95% of the syntax we kept the standard fpdf2 syntax.

For the rest - you can check the clone link example above or go directly to the source code on the github repository.

1 Like

Thank you very much for fast answer !
fastPdf - fast answer))

Hello Mark,

Do you know how to send write generated PDF by Anvil’s email system?

so that I want to write PDF file to Database table - how to do it if you don’t know how to send by email?

Hello Mark,

How set file of pdf file name with code?

Both of those questions are related to anvil rather than this package, since you get a “standard” anvil media object.

If you search the forum on
how to rename anvil media files and send anvil media via email
you should get plenty of hits.

basically you do:
pdf_media = doc.to_blob(‘filename’)
#send this per mail, store it in a data table …

I just using and it get as file.pdf

Hi Mark,

how do I use your fastPDF with a form.
With PDFRenderer it is like:

pdf = anvil.pdf.PDFRenderer(scale=0.75, page_size=‘A4’, filename=file_name).render_form(form_to_use)

Is it possible to use the form with fastPDF as well?

Cheers Aaron

Short Answer you can’t.

I imagine it would be possible to render forms and then merge it with the fast pdf result but I have never tried.
In fact - the whole point of this lib is to move away from the form rendering in order to improve speed.

to get the idea: I have to shoot in all labels etc. with a position, right?