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")
NuGet Download
Install-Package 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.8just released

Key in blue circle

Get your free 30-day Trial Key instantly.

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
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required