IRONSOFTWAREHOME
Custom Fonts in HTML to PDF
from ironpdf import *
 
html_with_font = '''<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet">
                   <p style="font-family: \'Lobster\', serif; font-size:30px;" > Hello Google Fonts</p>'''
 
# Instantiate Renderer
renderer = ChromePdfRenderer()
renderer.RenderingOptions.WaitFor.RenderDelay(500)
 
# Create a PDF from an HTML string
pdf = renderer.RenderHtmlAsPdf(html_with_font)
 
# Export to a file or Stream
pdf.SaveAs("font.pdf")
pip install ironpdf
Custom Fonts in HTML to PDF

Custom Fonts in HTML to PDF

IronPDF for Python fetches and embeds Google Fonts in PDF documents, preserving custom typography from your HTML source exactly as it appears in a browser.

Getting Started

Include a Google Fonts <link> tag in your HTML string and apply the font family via inline CSS or a <style> block. Set a short WaitFor.RenderDelay to allow IronPDF time to download the font file before rendering begins.

Understanding the Code

  • <link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet">: Standard Google Fonts stylesheet link. IronPDF follows this link and downloads the font during rendering.
  • font-family: 'Lobster', serif: Applies the Google Font to the element. The serif fallback is used if the font fails to load.
  • WaitFor.RenderDelay(500): Gives the renderer time to fetch and apply the remote font before capturing the page. Increase this if fonts are still missing in the output.
  • RenderHtmlAsPdf(html_with_font): Renders the HTML - including the remotely loaded font - as a PDF.

Font Embedding

IronPDF embeds the downloaded font directly in the output PDF, ensuring the document displays correctly on any system even without internet access. For production environments with strict outbound network policies, consider hosting fonts locally and referencing them with a BaseUrl.

Learn to convert HTML to PDF with IronPDF for Python!

Ready to Get Started?

Version:2026.10just released

Key in blue circle

Get your free 30-day Trial Key instantly

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF for Python
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get a Quote, No Obligation
Your details will always be kept confidential.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Trusted by Millions of Engineers Worldwide
Get your free 30-day Trial Key instantly.
No credit card or account creation required
Python Module Download for PDF
Install with pip

Version: 2026.10

  1. Download and install Python 3.7+.
  2. Install pip from pypi.org if it isn't installed already.
  3. Execute the above command in the terminal.
Python PDF Module
Download Module

Version: 2026.10

Manually install into your project

  1. Download the package
  2. Run this command from the terminal
    pip install ironpdf-2026.10-py37-none-win_amd64.whi

Licenses from $999