编辑XPS文档 [英] Editing XPS document
本文介绍了编辑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?
推荐答案
你好,
如果你已经有2个FlowDocuments那么这很简单。
你需要做的就是添加第一个流的BlockCollection Blocks
记录第二个文档的Blocks
。
合并后出口到XPS。
以下为样本:
Hello,
If you already have 2 FlowDocuments then it is pretty easy.
All you need to do is add to theBlockCollection Blocks
of your first flow document theBlocks
of the second document.
Once merged export to XPS.
Here is a sample:
//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文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文