亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

OpenXML ComplexScript 字體未呈現

OpenXML ComplexScript 字體未呈現

C#
繁星coding 2021-08-29 17:57:43
我有以下程序可以生成一個示例 Word 文檔:using DocumentFormat.OpenXml;using DocumentFormat.OpenXml.Packaging;using DocumentFormat.OpenXml.Wordprocessing;namespace OpenXmlExample{    class Program    {        static void Main(string[] args)        {            string filePath = @"C:\Users\[Redacted]\Desktop\OpenXmlExample.docx";            using (WordprocessingDocument document = WordprocessingDocument.Create(filePath, WordprocessingDocumentType.Document))            {                // Create main part and body of document                MainDocumentPart mainPart = document.AddMainDocumentPart();                mainPart.Document = new Document();                Body body = mainPart.Document.AppendChild(new Body());                // Prototype code for generation of the document title                Paragraph paragraph = new Paragraph();                ParagraphProperties pPr = new ParagraphProperties                {                    Justification = new Justification { Val = JustificationValues.Center }                };                RunProperties rPr = new RunProperties                {                    RunFonts = new RunFonts { ComplexScript = new StringValue("Arial") },                    Bold = new Bold { Val = true },                    Caps = new Caps { Val = true },                    FontSize = new FontSize { Val = "32" },                    FontSizeComplexScript = new FontSizeComplexScript { Val = "36" }                };                Text t = new Text("Example Document");                Run r = new Run();                r.Append((OpenXmlElement) rPr.Clone());                r.Append(t);                pPr.Append((OpenXmlElement) rPr.Clone());                paragraph.Append(pPr);                paragraph.Append(r);                body.Append(paragraph);            }        }    }}它似乎工作得很好?!笆纠臋n”正確呈現,粗體和大寫,16pt 字體。但是,該ComplexScript = new StringValue("Arial")部分似乎不起作用。文本僅以默認字體呈現。任何人都可以幫助我了解我是否做錯了什么?如果我將該Ascii屬性設置為 Arial,它似乎可以工作,但我希望將其生成為<w:rFonts w:cs="Arial"/>標簽。
查看完整描述

1 回答

?
HUH函數

TA貢獻1836條經驗 獲得超4個贊

對于單次運行,可以配置 4 種不同的字體。
這些字體中的每一種的使用應由運行內容的 Unicode 字符值確定。

Unicode 范圍內的字符的ASCII (U+0000-U+007F)。
復雜腳本的復雜的腳本Unicode的范圍,例如字符。阿拉伯文。
東亞用于東亞 Unicode 范圍內的字符,例如。日本人。Unicode 范圍內不屬于其他類別之一的字符的
高 ANSI。

'EXAMPLE DOCUMENT' 中的字符都屬于 ASCII 組,因此將應用相應組的字體。

MSDN和Office Open XML 中的更多詳細信息。


查看完整回答
反對 回復 2021-08-29
  • 1 回答
  • 0 關注
  • 202 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號