【发布时间】:2019-01-08 11:08:27
【问题描述】:
将文本从单词复制到另一个单词是否也会复制未使用的引用字体?如果是,有没有办法只检测使用的字体而不迭代整个段落? 谢谢你
【问题讨论】:
标签: aspose aspose.words
将文本从单词复制到另一个单词是否也会复制未使用的引用字体?如果是,有没有办法只检测使用的字体而不迭代整个段落? 谢谢你
【问题讨论】:
标签: aspose aspose.words
您必须遍历 Run 节点以获取有关文档中实际使用的字体的信息。请使用以下代码获取所需信息。
NodeCollection runs = dstDoc.GetChildNodes(NodeType.Run, true);
foreach(Run run in runs) {
Console.WriteLine("Font Name: {0}", run.Font.Name);
}
希望,这会有所帮助。
我与 Aspose 一起担任开发人员宣传员。
【讨论】:
是的,Aspose.Words 也会复制未使用的引用字体。请使用以下代码获取有关文档中使用的所有字体的信息。
Document doc = new Document(MyDir + "Document.doc");
FontInfoCollection fonts = doc.FontInfos;
int fontIndex = 1;
// The fonts info extracted from this document does not necessarily mean that the fonts themselves are
// used in the document. If a font is present but not used then most likely they were referenced at some time
// and then removed from the Document.
foreach (FontInfo info in fonts)
{
// Print out some important details about the font.
Console.WriteLine("Font #{0}", fontIndex);
Console.WriteLine("Name: {0}", info.Name);
Console.WriteLine("IsTrueType: {0}", info.IsTrueType);
fontIndex++;
}
希望,这会有所帮助。
我与 Aspose 合作,担任开发人员宣传员。
【讨论】: