1

I'm write a app to print some texts to pdf, but when I put a emoji like ❤️ and I try to print this using window.print, the emojis lost format, lost colors.

enter image description here

why this happens? what can I do to print this div with the emojis?

  • 4
    Emojis are UTF characters. Hence, different programs interpret them differently. You will need an emoji "font" or a reader than incorporates Emoji fonts. But the best way would be to replace all Emojis with images, (i.e. the old school way) before generating the PDF. – Ronnie Oct 20 '21 at 21:31

1 Answers1

1
  1. Use @font-face to embed a font that contains emoji (I think that is quite rare, but this seems a contender: https://emojisymbols.com/).

  2. Use @font-face to embed an icon font and wrap all emoji in spans that use that specific icon font.

  3. Write javascript* that replaces all emoji with images just before you fire the print command, like this:

    onclick="replaceAllEmojiWithImages(); window.print();"
    

*The javascript function can be derived from: https://stackoverflow.com/a/64007175/2397550

Mr. Hugo
  • 11,887
  • 3
  • 42
  • 60