Generate PDFs with Python

A simple API for filling out PDFs from your app.

A simple API for generating PDFs within your app. Write Python to send HTML & CSS or Markdown to Anvil, get back a PDF.
Hero Image

Perfectly formatted PDFs

Create dynamic and variable length PDFs with adjustments based on your content. Each page is perfectly scaled to a standard 8.5” x11” paper size.


Python to PDF

Use Python to lay out and generate your PDF for a 100% pixel perfect document.

def get_data():
  return {
      "title": "Example HTML to PDF",
      "type": "html",
      "data": {
          "html": """
              <h1 class='header-one'>What is Lorem Ipsum?</h1>
              <p>
                  Lorem Ipsum is simply dummy text of the printing and typesetting
                  industry. Lorem Ipsum has been the industry's standard dummy text
                  ever since the <strong>1500s</strong>, when an unknown printer took
                  a galley of type and scrambled it to make a type specimen book.
              </p>
          """,
          "css": """
              body { font-size: 14px; color: #171717; }
              .header-one { text-decoration: underline; }
          """
      },
  }

def generate_html_pdf():
  anvil = Anvil(api_key=API_KEY)
  payload = get_data()

  print("Making HTML PDF generation request...")

  res = anvil.generate_pdf(payload)

  # Write the bytes to disk
  with open(FILE_OUTPUT, "wb") as f:
      f.write(res)

  print("Finished!")

Try it now


SOC2 logo
GDPR logo
HIPAA logo
EIDAS logo