I cannot get colored emojis to work when converting from html to pdf. I have tried this in both Windows (where I have “Segoe UI Emoji” colored fonts) and in Linux with (with Google Noto font).
I attached a zip file with a couple sample html files.
The code is simple.
var optionsHtml = new Aspose.Pdf.HtmlLoadOptions()
{
PageInfo = new PageInfo() {
IsLandscape = false
},
IsRenderToSinglePage = false,
PageLayoutOption = HtmlPageLayoutOption.None,
DisableFontLicenseVerifications = true,
};
using (var document = new Document("C:\\testdocs\\TEST1.htm", optionsHtml))
{
var saveOptions = new Aspose.Pdf.PdfSaveOptions()
{
};
document.Save(tempPath, saveOptions);
}
To ensure colored emojis are rendered correctly when converting HTML to PDF using Aspose.PDF, it is essential to embed a font that supports colored emojis in the PDF. Here are the steps you can follow:
Use a Font that Supports Emojis: Ensure that the font you are using (such as “Segoe UI Emoji” or “Noto Color Emoji”) is correctly referenced in your HTML and is available on the system where the conversion is taking place.
Embed Fonts in PDF: You can specify font embedding in your PDF save options. Here’s how to modify your code:
var optionsHtml = new Aspose.Pdf.HtmlLoadOptions()
{
PageInfo = new PageInfo() {
IsLandscape = false
},
IsRenderToSinglePage = false,
PageLayoutOption = HtmlPageLayoutOption.None,
DisableFontLicenseVerifications = true,
};
using (var document = new Document("C:\\testdocs\\PREPROD_00000113.htm", optionsHtml))
{
var saveOptions = new Aspose.Pdf.PdfSaveOptions()
{
// Ensure fonts are embedded
EmbedFullFonts = true
};
document.Save(tempPath, saveOptions);
}
Check HTML for Correct Font Usage: Ensure your HTML specifies the correct font for emojis. You can use CSS to set the font-family as follows:
body {
font-family: 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}
Test on Different Platforms: If you are testing on both Windows and Linux, ensure that the font files are accessible and correctly installed on both systems.
If you continue to experience issues, consider reviewing the Aspose documentation for any specific limitations or additional settings that may be required for emoji rendering.
I am unable to make colored emojis work when creating a pdf from html using Aspose.PDF 25.9. I have tried setting the font family to include both ‘Segoe UI Emoji’, and ‘Noto Color Emoji’ and have tried embedding fonts. The ‘Segoe UI Emoji’ font does show as being embedded in the PDF. Is there a way to make this work using Aspose.PDF, it seems like a pretty basic thing to want color emojis in a PDF. I have also tried using Aspose.Html.Converters.Converter.ConvertHTML() but that did not work either. I have attached 2 samples htm files and also the 2 rendered pdfs. If I cut and paste the black and white icons out of the generated pdf into MSWord, it pastes them in color so something is telling them to be rendered as black and white in the pdf.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFNET-60837
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.