I'm creating a FixedDocument
by adding FixedPages
to PageContents
, then adding them to the FixedDocument
somehow like this
FixedDocument fd = new FixedDocument();
// add FixedPages in PageContent to fd
Printing them with a PrintDialog
, like this
pdialog.PrintDocument(fd.DocumentPaginator, "Test");
results in the correct number of pages. However, every page printed - e.g. to a PDF - is the content of the first page.
I tried testing the ImageSources
I add to the FixedPages
, those seem correct. I also tested the final FixedDocument
with a DocumentViewer
like so
Window wnd = new Window();
DocumentViewer viewer = new DocumentViewer();
viewer.Document = fd;
wnd.Content = viewer;
try
{
wnd.Show();
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
This strangely shows the correct output I would expect. What's even stranger is that I get an IOException
after wnd.Show();
(which is why I surrounded it with a try/catch). Even with the try catch I can only view it maybe 1-2 seconds before the same IOException
thrown by my MainWindow
. Something like "Wrong username or password" - which doesn't make sense, since the images I'm trying to print are local ones.
Putting the DocumentViewer
aside, my problem with the Print()
method only printing the first page n times (n being the number of actual pages it should be) still persists, just thought that the exception in the DocumentViewer
may give someone an idea of an underlying problem.
This might be a possible duplicate of FixedDocument always print first page - however he doesn't mention problems with DocumentViewer
and the question remains unanswered.
Thanks in advance for any help!