I'm trying to get a FlowDocument to print. After spending much of the day trying multiple pages I failed and opted for something simpler, but I'm now at a loss to explain when text isn't output to the page. This has to be something I've got snowblind to I think. There are two tables below, placing a converter on both shows that the values are being populated through the DataContext of the FlowDocument.
<Table>
<Table.Columns>
<TableColumn Width="Auto"/>
<TableColumn Width="34"/>
<TableColumn Width="Auto"/>
</Table.Columns>
<TableRowGroup>
<TableRow>
<TableCell>
<Paragraph>
<Image Source="{Binding Icon,Converter={StaticResource IconConverter},ConverterParameter=32}" Width="32" Height="32"/>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph>
<TextBlock Text="{Binding Name,Converter={StaticResource dbg}}" TextWrapping="Wrap" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" FontSize="18" Foreground="Black" />
</Paragraph>
</TableCell>
<TableCell>
<Paragraph>
<TextBlock Text="Static text works fine" TextAlignment="Right" />
<TextBlock Text="Static text works here too fine" TextAlignment="Right" />
</Paragraph>
</TableCell>
</TableRow>
</TableRowGroup>
</Table>
<BlockUIContainer>
<Line Stretch="Fill" Stroke="DarkBlue" X2="1"/>
</BlockUIContainer>
The document is printed using:
PrintDialog dlg = new PrintDialog();
if(dlg.ShowDialog() == true) {
int margin = 5;
Size pageSize = new Size(dlg.PrintableAreaWidth - margin * 2, dlg.PrintableAreaHeight - margin * 2);
FlowDocument document = WPFUtils.LoadFlowDocument(System.IO.Path.Combine(Utils.GetApplicationPath(), "AccountPrintView.xaml"), account); // loads the document from a XAML file
IDocumentPaginatorSource paginator = document as IDocumentPaginatorSource;
paginator.DocumentPaginator.PageSize = pageSize;
dlg.PrintDocument(paginator.DocumentPaginator, "Print output");
}
I'm sort of at my wits end with this, I can't see the problem. I'd really appreciate it if anyone could shed some light.