TextConverter
内容
[
隐藏
]FieldIncludeText.TextConverter property
获取或设置包含文件格式的文本转换器的名称。
public string TextConverter { get; set; }
例子
演示如何创建 INCLUDETEXT 字段并设置其属性。
public void FieldIncludeText()
{
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// 下面是使用 INCLUDETEXT 字段显示本地文件系统中 XML 文件内容的两种方法。
// 1 - 对 XML 文档执行 XSL 转换:
FieldIncludeText fieldIncludeText = CreateFieldIncludeText(builder, MyDir + "CD collection data.xml", false, "text/xml", "XML", "ISO-8859-1");
fieldIncludeText.XslTransformation = MyDir + "CD collection XSL transformation.xsl";
builder.Writeln();
// 2 - 使用 XPath 从 XML 文档中获取特定元素:
fieldIncludeText = CreateFieldIncludeText(builder, MyDir + "CD collection data.xml", false, "text/xml", "XML", "ISO-8859-1");
fieldIncludeText.NamespaceMappings = "xmlns:n='myNamespace'";
fieldIncludeText.XPath = "/catalog/cd/title";
doc.UpdateFields();
doc.Save(ArtifactsDir + "Field.INCLUDETEXT.docx");
}
/// <summary>
/// 使用文档生成器插入具有自定义属性的 INCLUDETEXT 字段。
/// </summary>
public FieldIncludeText CreateFieldIncludeText(DocumentBuilder builder, string sourceFullName, bool lockFields, string mimeType, string textConverter, string encoding)
{
FieldIncludeText fieldIncludeText = (FieldIncludeText)builder.InsertField(FieldType.FieldIncludeText, true);
fieldIncludeText.SourceFullName = sourceFullName;
fieldIncludeText.LockFields = lockFields;
fieldIncludeText.MimeType = mimeType;
fieldIncludeText.TextConverter = textConverter;
fieldIncludeText.Encoding = encoding;
return fieldIncludeText;
}
也可以看看
- class FieldIncludeText
- 命名空间 Aspose.Words.Fields
- 部件 Aspose.Words