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.6 just released
Still Scrolling Icon

Still Scrolling?

Want proof fast?
run a sample watch your HTML become a PDF.