简体   繁体   English

如何将带有表情符号“❤️”的 div 打印为 pdf

[英]How to print an div with emoji "❤️" to pdf

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.我正在编写一个应用程序来将一些文本打印为 pdf,但是当我放了一个像 ❤️😬 这样的表情符号并且我尝试使用 window.print 打印它时,表情符号丢失了格式,丢失了颜色。

在此处输入图片说明

why this happens?为什么会这样? what can I do to print this div with the emojis?我该怎么做才能用表情符号打印这个 div?

  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/ ).使用 @font-face 嵌入包含表情符号的字体(我认为这很罕见,但这似乎是一个竞争者: https : //emojisymbols.com/ )。

  2. Use @font-face to embed an icon font and wrap all emoji in spans that use that specific icon font.使用 @font-face 嵌入图标字体并将所有表情符号包装在使用该特定图标字体的跨度中。

  3. Write javascript* that replaces all emoji with images just before you fire the print command, like this:编写 javascript*,在您触发打印命令之前用图像替换所有表情符号,如下所示:

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

*The javascript function can be derived from: https://stackoverflow.com/a/64007175/2397550 *javascript 函数可来源于: https : //stackoverflow.com/a/64007175/2397550

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM