Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
To render emoji in an HtmlRenderer.PdfSharp PDF, use valid Unicode text and make sure the font selected for that text contains the emoji glyphs. Unicode encoding preserves the characters; it cannot make a font support a glyph it does not have. Register or map an emoji-capable font before generating the PDF, then test the exact PDFsharp version and deployment environment you ship.
Why emoji turn into boxes or disappear
HtmlRenderer.PdfSharp delegates text creation to PDFsharp. Its adapter constructs an XFont using PdfFontEncoding.Unicode, and PdfGenerator.GeneratePdf converts the HTML into a PDF document. Unicode mode matters because it allows the text to be represented as Unicode, but it does not supply missing glyphs. If the resolved font does not contain an emoji, the result can be a blank, a square (often called tofu), or another fallback glyph.
There are therefore two separate checks: the HTML must reach the renderer as valid Unicode, and the font chosen during PDF generation must cover the characters. Changing only the encoding addresses neither a missing font file nor missing glyph coverage.
Supply an emoji-capable font
PDFsharp’s documentation uses Segoe UI Emoji in examples. You can bundle an emoji-capable TTF or OTF with your application, or install it in a controlled runtime image. Do not assume that a font installed on a developer’s Windows workstation will also exist on a Linux server or in a container.
#1 Best Overall
Register the font directory and map the CSS family
Register the directory before the first PDF is generated. If the HTML asks for a family name that differs from the actual installed font family, map the requested name to the family you supply:
PdfGenerator.RegisterCustomFontDirectory("./fonts");
PdfGenerator.AddFontFamilyMapping("EmojiFont", "Segoe UI Emoji");
var pdf = await PdfGenerator.GeneratePdf(
"<p style="font-family: EmojiFont">Hello 🌹 😍</p>",
PageSize.A4);
Put the font file in the registered directory and ensure that the process can read it. AddFontFamilyMapping is a fallback substitution when a requested family is not found; it is not a way to add characters to a font that lacks them. In production, use a mapping and family name that match the font you actually deploy, and verify the resolved font with a generated PDF.
Use a CSS font-face resource when that fits your HTML
You can also provide a local or remote CSS @font-face. HtmlRenderer.PdfSharp’s adapter routes the font resource to PDFsharp’s resolver, so the family can be recognized for layout. Confirm that the resource is reachable and that the deployed renderer resolves it as expected. A CSS declaration alone is not proof that the intended font was embedded or used.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchRank #2
Handle emoji as .NET Unicode text
Many emoji are outside the Basic Multilingual Plane. .NET represents those characters in UTF-16 as a pair of code units, called a surrogate pair. For example, U+1F339 (🌹) can be represented as "ud83cudf39"; modern C# source can also contain the literal character.
string rose = "ud83cudf39";
string html = $"<p style="font-family: EmojiFont">Hello {rose} 😍</p>";
var pdf = await PdfGenerator.GeneratePdf(html, PageSize.A4);
Keep the input intact from source or data store through HTML construction. Decode HTML as UTF-8 where appropriate, and do not replace unsupported characters with ? or create invalid surrogate sequences. When output is wrong, inspect the actual HTML string as well as the font resolution; the visible source text and the PDF’s selected font are independent parts of the path.
Know what to expect from emoji color
Standard PDFsharp output is generally monochrome for emoji. PDFsharp’s documentation cautions that emoji in a PDF will not necessarily look like their browser counterparts, attributing the difference to the lack of a standard PDF colored-character specification. A font that has the character can solve a missing-glyph problem without producing browser-equivalent color or styling.
PDFsharp documents PdfFontColoredGlyphs.Version0 as an option for colored glyph output in PDFsharp 6.2.0 Preview 1. That is a version-specific preview feature, not a guarantee for every PDFsharp release, font, or PDF viewer. If color is a requirement, verify the precise package version, supported font format and glyphs, and the viewers your recipients use before promising the result.
Free tools Windows power users keep installed
One-click scans. No signup required.
Choose a font approach for your deployment
| Approach | Useful when | Check before shipping |
|---|---|---|
| Bundle a TTF or OTF and register its directory | You control the application package and want the same font asset available across hosts. | Confirm font coverage, file availability, runtime read access, and the font’s license for your use. |
| Install the font in a controlled runtime image | You manage a fixed host or container image and maintain its font inventory. | Confirm the image used in production contains the font; a workstation installation is not portable. |
| Map the requested CSS family to an available family | Your HTML uses a stable logical name such as EmojiFont. |
Ensure the mapped family exists and contains every character required by the document. |
Provide the font through CSS @font-face |
The HTML already manages font resources and the resolver can access them. | Check resource loading and actual font resolution in the PDFsharp adapter. |
PDFsharp’s resolver documentation describes sample and unit-test resolvers and notes that extracted samples still require the application to provide both the resolver and font assets. Treat samples as implementation references, not as a production font deployment that happens automatically.
Troubleshoot a missing, broken, or monochrome emoji
- A question mark appears: Check whether the original HTML string already contains
?or malformed text. Preserve UTF-8 input and valid UTF-16 surrogate pairs before investigating font fallback. - A square or tofu glyph appears: Inspect which family was resolved and whether that font covers the exact code point. Unicode encoding cannot add a missing glyph.
- The result differs between development and production: Check that the production host or container has the font file, that its path is correct, and that the process can read it. Register the directory or configure the resolver before PDF generation starts.
- Some emoji work but others do not: Check the font’s coverage for each character in the affected text. Compound emoji can involve supplementary-plane characters, variation selectors, or a zero-width-joiner (ZWJ) sequence; coverage of one familiar emoji does not establish coverage of every sequence.
- The emoji is present but black and white: Separate glyph availability from colored-glyph output. Check the PDFsharp version and its colored-glyph support, then test the resulting PDF in the target viewer.
- A CSS font seems ignored: Verify the family name in the HTML, the CSS cascade, and whether the font resource reaches PDFsharp’s resolver. A mapping can help when the requested family is not found, but must point to an available family.
Performance, reliability, and licensing considerations
The available PDFsharp guidance does not establish a numeric performance cost for emoji fonts, a speed ranking among registration approaches, or a universal reliability guarantee. Avoid assuming that a particular setup is faster without measuring it in your own application. For reliable output, make font provisioning part of the deployment artifact or image, initialize font registration or the resolver before generation, and include representative emoji in a PDF smoke test for each runtime you support.
Rank #4
Font coverage and font licensing are distinct questions. Check the license for the specific font file and the way you intend to distribute or use it; the font’s presence on a development machine does not itself establish redistribution rights. Also test the actual PDF viewers and downstream workflows your readers use, especially when colored glyphs or complex emoji sequences matter.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server, not a replacement for HtmlRenderer.PdfSharp’s font configuration: it does not give you control over how a C# PDF renderer chooses emoji glyphs. If the task is instead to capture a rendered web page as an image or PDF, one GET request can do that:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. It removes supported cookie and consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents take screenshots, and the free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Those capture features are useful for webpage screenshots, but they are separate from choosing an emoji font in a generated C# PDF. Learn about ScreenshotNeo or sign up for 1,000 free screenshots a month with no card.
Frequently asked questions
Does registering a font directory install the font on every machine?
No. Registration makes font files in the specified directory available to the application; your deployment still needs to include those files or provide them through its configured runtime.
Best Value
Can I promise full color emoji by enabling the preview option?
No. The documented colored-glyph option is version-sensitive, and the result depends on the supported font and PDF viewer combination. Validate that exact combination before setting expectations.
Frequently Asked Questions
Does registering a font directory install the font on every machine?
No. Registration makes font files in the specified directory available to the application; your deployment still needs to include those files or provide them through its configured runtime.
Can I promise full color emoji by enabling the preview option?
No. The documented colored-glyph option is version-sensitive, and the result depends on the supported font and PDF viewer combination. Validate that exact combination before setting expectations.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

