我正在尝试生成包含一些表情符号的 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 字符将无法正确显示。
关于c# - 如何使用 MigraDoc 让表情符号出现在生成的 PDF 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58747029/