Aspose代码正在插入默认日期的视图母版(垂直),以便在其中选择文本。我想用图片中所示的文字来代替。
按照ViewMaster(vertical) using Aspose中提到的代码生成word/pdf中的ViewMaster(垂直)。有人能帮我找到正确的代码用文本替换日期吗?

发布于 2022-08-10 05:01:24
日期在结构化文档标记中设置。您可以使用这样的代码获取和修改此SDT的值:
// Get structured document tags from footer.
NodeCollection tags = doc.FirstSection.HeadersFooters[HeaderFooterType.FooterPrimary].GetChildNodes(NodeType.StructuredDocumentTag, true);
foreach (StructuredDocumentTag tag in tags)
{
if (tag.Title.Equals("Date") && tag.SdtType == SdtType.Date)
{
tag.IsShowingPlaceholderText = false;
tag.FullDate = DateTime.Now;
// By default SDT is minded to XML. We can simply remove mapping to use value set in FullDate property.
tag.XmlMapping.Delete();
}
}如果不需要日期,但需要插入一些自定义文本,则可以移除标记并插入一个带有文本的简单段落。例如:
// Get structured document tags from footer.
NodeCollection tags = doc.FirstSection.HeadersFooters[HeaderFooterType.FooterPrimary].GetChildNodes(NodeType.StructuredDocumentTag, true);
foreach (StructuredDocumentTag tag in tags)
{
if (tag.Title.Equals("Date") && tag.SdtType == SdtType.Date)
{
// Put an empty paragraph ater the structured document tag
Paragraph p = new Paragraph(doc);
tag.ParentNode.InsertAfter(p, tag);
// Remove tag
tag.Remove();
// move DocumentBuilder to the newly inserted paragraph and insert some text.
builder.MoveTo(p);
builder.Write("This is my custom vertical text");
}
}https://stackoverflow.com/questions/73300138
复制相似问题