.NET C#-MigraDoc-如何更改文档字符集? [英] .NET C# - MigraDoc - How to change document charset?

查看:103
本文介绍了.NET C#-MigraDoc-如何更改文档字符集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找解决此问题的方法,但仍然找不到答案.任何帮助将不胜感激.

I've searched for solution to this problem, but still cannot find the answer. Any help would be appreciated.

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

    Paragraph paragraph = section.AddParagraph();

    paragraph.Format.Font.Color = Color.FromCmyk(100, 30, 20, 50);

    paragraph.AddText("ąčęėįųųūū");

    paragraph.Format.Font.Size = 9;
    paragraph.Format.Alignment = ParagraphAlignment.Center; 
    </b>

< ...>

在上面的示例中,字符±čęėįųųūū"未显示在导出的pdf中.

In example above characters "ąčęėįųųūū" are not displayed in exported pdf.

如何设置"MigraDoc"字符集?

How can I set 'MigraDoc' character set ?

推荐答案

只需告诉渲染器创建Unicode文档:

Just tell the Renderer to create an Unicode document:

PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);
renderer.Document = document;

PdfDocumentRenderer的第一个参数必须为true以获取Unicode. 请注意,并非所有True Type字体都包含所有Unicode字符(但应与Arial,Verdana等一起使用).

The first parameter of PdfDocumentRenderer must be true to get Unicode. Please note that not all True Type fonts include all Unicode characters (but it should work with Arial, Verdana, etc.).

有关完整示例,请参见此处: http://www.pdfsharp.net/wiki/HelloMigraDoc-sample.ashx

See here for a complete sample: http://www.pdfsharp.net/wiki/HelloMigraDoc-sample.ashx

这篇关于.NET C#-MigraDoc-如何更改文档字符集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆