本文介绍了编辑XPS文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在以下代码的帮助下创建了XPS文档:
Hi,
I created XPS document with the help of below code:
XpsDocument xpsDocument = new XpsDocument(packageName, FileAccess.ReadWrite);
XpsSerializationManager xpsSerializationManager = new XpsSerializationManager(new XpsPackagingPolicy(xpsDocument), false);
DocumentPaginator documentPaginator = ((IDocumentPaginatorSource)flowDocument).DocumentPaginator;
xpsSerializationManager.SaveAsXaml(documentPaginator);
xpsDocument.Close();
现在我想在另一个FlowDocument对象中添加更多数据到同一个XPS文档。请告诉我怎么做?
Now I want to add some more data which is in another FlowDocument object to the same XPS document. Please let me know how to do it?
推荐答案
//create a flow document
Paragraph paragraph = new Paragraph();
paragraph.Inlines.Add("This is a bit of text");
FlowDocument document1 = new FlowDocument(paragraph);
//create another flow document
Paragraph paragraph2 = new Paragraph();
paragraph2.Inlines.Add("this is another one!");
FlowDocument document2 = new FlowDocument(paragraph2);
// append document2 to document1
for (int i = 0; i < document2.Blocks.Count; i++)
{
document1.Blocks.Add(document2.Blocks.ElementAt(i));
}
//save to xps
XpsDocument xpsDocument = new XpsDocument(@"C:\temp\test.xps", FileAccess.ReadWrite);
XpsSerializationManager xpsSerializationManager = new XpsSerializationManager(new XpsPackagingPolicy(xpsDocument), false);
DocumentPaginator documentPaginator = ((IDocumentPaginatorSource)document1).DocumentPaginator;
xpsSerializationManager.SaveAsXaml(documentPaginator);
xpsDocument.Close();
Valery。
Valery.
这篇关于编辑XPS文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!