Hello,
If you already have 2 FlowDocuments then it is pretty easy.
All you need to do is add to the
BlockCollection Blocks
of your first flow document the
Blocks
of the second document.
Once merged export to XPS.
Here is a sample:
Paragraph paragraph = new Paragraph();
paragraph.Inlines.Add("This is a bit of text");
FlowDocument document1 = new FlowDocument(paragraph);
Paragraph paragraph2 = new Paragraph();
paragraph2.Inlines.Add("this is another one!");
FlowDocument document2 = new FlowDocument(paragraph2);
for (int i = 0; i < document2.Blocks.Count; i++)
{
document1.Blocks.Add(document2.Blocks.ElementAt(i));
}
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.