[Public] Emojis Not Rendering in IronPDF Using RenderHtmlAsPdf()
Issue workaround
IronPDF is a powerful library for converting HTML to PDF in .NET applications. However, developers using RenderHtmlAsPdf()
may run into a subtle issue when trying to render Unicode emojis: the emojis are missing from the output PDF, even though the same HTML renders correctly in Chrome.
This article highlights the issue, shows how to reproduce it, and introduces workarounds that ensure emoji characters are properly rendered.
Issue Description
When rendering a string of HTML containing Unicode emojis using:
var pdf = renderer.RenderHtmlAsPdf(htmlString);
The resulting PDF does not display the emoji characters, even though:
-
The emojis are visible in browser print preview (e.g. Chrome)
-
The HTML is valid and UTF-8 encoded
-
The rest of the content renders correctly
Minimal Reproduction Example
Actual Output:
-
PDF renders text but omits or replaces emojis with blank spaced
Expected Output:
-
Emojis render correctly, as seen in Chrome Print Preview.
Workarounds
1. Use RenderHtmlFileAsPdf()
Instead
Instead of rendering from a string, write the HTML to a file and use:
This method ensures the rendering engine processes the file in a context closer to a real browser, improving Unicode and emoji handling.
2. Use Numeric Character References for Emojis
If you're generating HTML dynamically, convert emoji characters to numeric HTML entities.
Example:
Replace 👋 (U+1F44B) with:
👋
So the HTML becomes:
<p>Hello 👋, this is a test 😊</p>
This allows IronPDF to bypass encoding issues and render the emojis as glyphs.
Summary
Method | Emoji Rendering | Recommended |
---|---|---|
RenderHtmlAsPdf(string) |
❌ May fail | 🚫 Avoid for emojis |
RenderHtmlFileAsPdf(file) |
✅ Works | ✅ Use this |
Unicode → Numeric Entities | ✅ Works | ✅ Use when generating HTML programmatically |
Recommendation
If your PDF output includes Unicode emojis, use either:
-
RenderHtmlFileAsPdf()
, or -
Replace emojis with numeric HTML entities
This ensures consistent, cross-platform emoji rendering — especially in production environments where silent failures (like missing glyphs) can go unnoticed.