Embedding Custom Fonts in IronPDF on Linux Docker Containers
Custom fonts embed correctly when generating PDFs on Windows but fail to embed inside a Linux Docker container. Instead of the intended font, the renderer uses DejaVu Sans as a fallback.
On Linux systems and inside Docker containers, fonts must be explicitly installed or referenced. If a font is not available to the Chrome rendering engine, IronPDF substitutes the system's default fallback font, causing visual differences and embedding failures.
Solution
Option 1: Install Microsoft core fonts for Arial and similar fonts
Add to your Dockerfile:
RUN apt update && apt install -y ttf-mscorefonts-installer
Option 2: Embed custom fonts via @font-face
For non-system fonts such as Poppins or Roboto, declare them in HTML using @font-face with a path to a .ttf file bundled inside the Docker image:
<!DOCTYPE html>
<html>
<head>
<style>
@font-face {
font-family: 'Poppins';
src: url('fonts/Poppins-Regular.ttf');
}
p {
font-family: 'Poppins';
font-size: 16px;
}
</style>
</head>
<body>
<p>Custom font text</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
@font-face {
font-family: 'Poppins';
src: url('fonts/Poppins-Regular.ttf');
}
p {
font-family: 'Poppins';
font-size: 16px;
}
</style>
</head>
<body>
<p>Custom font text</p>
</body>
</html>
Option 3: Use the Print CSS media type
Set CssMediaType to apply print-specific styles, including @font-face declarations:
renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print;
renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print;
renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print
For a complete Linux Docker setup, see the IronPDF Docker guide.

