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>
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
$vbLabelText   $csharpLabel

For a complete Linux Docker setup, see the IronPDF Docker guide.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...

Read More
Ready to Get Started?
Nuget Downloads 19,345,590 | Version: 2026.6 just released
Still Scrolling Icon

Still Scrolling?

Want proof fast? PM > Install-Package IronPdf
run a sample watch your HTML become a PDF.