HTML to PDF does not create colored emojis

test_files.zip (10.5 KB)

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);
                }

@skowald

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:

  1. 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.

  2. 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);
}
  1. 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;
}
  1. 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.