I have a Blazor
app that connects to an existing backend. The Blazor app needs to print data from a List<T>
. What is the correct way of doing this?
In the WPF world, I would use a DocumentPaginator
, however, since a DocumentPaginator
GetPage
method returns a DocumentPage
which is a WPF Visual
element this is out.
I have some luck creating a FlowDocument
Something like this:
var doc = new FlowDocument();
var table1 = new Table();
doc.Blocks.Add(table1);
for (int x = 0; x < numberOfFields; x++)
{
table1.Columns.Add(new TableColumn());
}
table1.RowGroups.Add(new TableRowGroup());
int i = 0;
foreach (var x in MyList)
{
table1.RowGroups[0].Rows.Add(new TableRow());
TableRow currentRow = table1.RowGroups[0].Rows[i];
AddFields(currentRow, i, x);
i++;
}
That prints out a document however, I need page headers and footers. Placing headers, footers, and page breaks can be done with Paragraph
and Section
are simple enough. The problem is calculating when to apply the page break. Everything I have seen to find out the height of something in FlowDocument uses a FrameworkElement
to find it.
Very new to web, so if there is some simple solution I am sorry for asking.