I want to create a document with several pages and with one wpf window depicted on each page.
I managed to print one window using PrintDialog and PrintVisual. Howeve
You want to create a FixedDocument
with multiple FixedPages
.
Example:
How to create a new document and single page.
var pageSize = new Size(8.26 * 96, 11.69 * 96); // A4 page, at 96 dpi
var document = new FixedDocument();
document.DocumentPaginator.PageSize = pageSize;
// Create FixedPage
var fixedPage = new FixedPage();
fixedPage.Width = pageSize.Width;
fixedPage.Height = pageSize.Height;
// Add visual, measure/arrange page.
fixedPage.Children.Add((UIElement)visual);
fixedPage.Measure(pageSize);
fixedPage.Arrange(new Rect(new Point(), pageSize));
fixedPage.UpdateLayout();
// Add page to document
var pageContent = new PageContent();
((IAddChild)pageContent).AddChild(fixedPage);
document.Pages.Add(pageContent);
// Send to the printer.
var pd = new PrintDialog();
pd.PrintDocument(document.DocumentPaginator, "My Document");
Written in C#, however you should be able to convert to VB.
HTH,