c# - 如何使用 MigraDoc 让表情符号出现在生成的 PDF 中

标签 c# pdf pdf-generation emoji migradoc

我正在尝试生成包含一些表情符号的 PDF,但没有成功。 为了使其简单且可重现,这里是代码:

    Document document = new Document();
    Section section = document.AddSection();


    Paragraph paragraph = section.AddParagraph();
    paragraph.AddFormattedText("👀 😀 💨 ♡", new Font("Segoe UI Emoji"));


    PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);
    pdfRenderer.Document = document;
    pdfRenderer.RenderDocument();


    var memoryStream = new MemoryStream();
    var path = Path.GetTempFileName() + ".pdf";
    pdfRenderer.PdfDocument.Save(path);
    Process.Start(path);

但不幸的是,出现了空矩形:

��

最佳答案

这是 PDFsharp 的已知限制。代理对尚不工作,需要两个 16 位值(0xffff 以上)的 Unicode 字符将无法正确显示。

另请参阅:
https://github.com/empira/PDFsharp-1.5/issues/63

关于c# - 如何使用 MigraDoc 让表情符号出现在生成的 PDF 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58747029/

相关文章:

r - 在 .pdf 文件上提取图像会产生异常的垂直条纹

java - 使用java创建、编辑和删除pdf文件

batch-file - 通过命令行使用苏门答腊pdf批量打印pdf

python - zlib解压后得到与原文件不同的大小

c# - Visual Studio 生成 MSI 安装程序、程序文件和管理员访问权限

c# - WPF 主题窗口控件以匹配 Telerik 的

python - 什么程序可以在 Linux 上从 Python 编写 pdf(包括其他 pdf)?

python - 在python中将excel转换为pdf

c# - 将 Console.WriteLine() 输出重定向到字符串

c# - 如何从 Fluent Api 检索实体配置