2

I need to save a large stackpanel to an XPS document. Since the stackpanel is lengthy, it cannot be accommodated in a single page while printing. Is there a way to save the stackpanel in XPS expanding multiple pages?

Below is my code that saves a single page:

Transform transform = stkpnlMain.LayoutTransform;
stkpnlMain.LayoutTransform = null;
Size size = new Size(stkpnlMain.ActualWidth, stkpnlMain.ActualHeight);
stkpnlMain.Measure(size);
stkpnlMain.Arrange(new Rect(size));

Package package = Package.Open(destination.LocalPath, FileMode.Create);
XpsDocument doc = new XpsDocument(package);
XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(doc);
writer.Write(stkpnlMain);

doc.Close();
package.Close();

Here, stkpnlMain is a very lengthy block.

  • Have a [look here](https://blogs.msdn.microsoft.com/fyuan/2007/03/10/convert-xaml-flow-document-to-xps-with-style-multiple-page-page-size-header-margin/) or refer [this](http://ericsink.com/wpf3d/B_Printing.html) – boop_the_snoot Jul 25 '17 at 12:01

0 Answers0