You can print the visual image on XPS. However, as I understand it, this is your job for managing pages. If your visual is too large to fit on the page, you need to find a way to divide it into several pages.
The source code that I posted here prints a list of elements on many pages:
https://bitbucket.org/paulstovell/samples/src/a323f0c65ea4/XPS%20Report%20Generator/
If you can find a way to divide your visual effects (maybe create 3 forms with 15 elements per form) into pages, you can use this:
using (var doc = new XpsDocument("P:\\Test2.xps", FileAccess.Write)) { var writer = XpsDocument.CreateXpsDocumentWriter(doc); var collator = writer.CreateVisualsCollator(); collator.BeginBatchWrite(); collator.Write(form1); collator.Write(form2); collator.Write(form3); collator.EndBatchWrite(); } var doc2 = new XpsDocument("P:\\Test2.xps", FileAccess.Read); var seq = doc2.GetFixedDocumentSequence(); var window = new Window(); window.Content = new DocumentViewer {Document = seq}; window.ShowDialog();
Also, note that if you create a visual visualization and print it, you need to define it first, otherwise you may get a blank screen. Here is an example of creating a data page (of course, you will resize to fit an A4 sheet).
private StackPanel CreatePage() { var panel = new StackPanel(); panel.Width = 1000; panel.Height = 1000; for (var i = 0; i < 10; i++) { panel.Children.Add(new TextBlock() {Text = "Item " + i}); } panel.Measure(new Size(1000, 1000)); panel.Arrange(new Rect(0, 0, 1000, 1000)); return panel; }
source share