How do I get FixedDocument to automatically paginate? I have the following code that I can use to put prettified Panel into a DocViewer. The problem occurs when the Panel extends past a single page. Right now, we simply clip. Basically, I want to create a fairly generic way to print what the user is viewing. Is my approach reasonable?
public void CreateReport(Panel details)
{
FixedDocument fixedDoc = new FixedDocument();
PageContent pageContent = new PageContent();
FixedPage fixedPage = new FixedPage();
fixedPage.DataContext = this.DataContext;
fixedPage.Margin = new Thickness(10);
fixedPage.Children.Add(details);
((System.Windows.Markup.IAddChild)pageContent).AddChild(fixedPage);
fixedDoc.Pages.Add(pageContent);
// This makes the array of controls invisibile, then climbs the details structure
// and makes the controls within details appropriate for the DocumentViewwer (i.e. TextBoxes are
// non-editable, no borders, no scroll bars, etc).
prePrintPrepare(details, fixedPage, new FrameworkElement[] { controlToMakeInvisible });
_dv = new DocViewer();
_dv.documentViewer1.Document = fixedDoc;
_dv.Show();
}
I hate answering my own question, but, the following gave me a reasonable solution: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/bd89e0d2-73df-4b9b-9210-b8be83ff29d6/
Scott