印花和 Blazor

Xap*_*ann 1 c# flowdocument blazor

我有一个Blazor连接到现有后端的应用程序。Blazor 应用程序需要打印来自List<T>. 这样做的正确方法是什么?

然而,在 WPF 世界中,我会使用 a DocumentPaginator,因为DocumentPaginator GetPage方法返回 a DocumentPage,它是一个 WPFVisual元素,所以这就不行了。

我很幸运地创建了FlowDocument这样的东西:

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++;
}
Run Code Online (Sandbox Code Playgroud)

但是,这会打印出一个文档,我需要页眉和页脚。放置页眉、页脚和分页符都可以完成,Paragraph而且Section非常简单。问题是计算何时应用分页符。我所见过的在 FlowDocument 中查找某物高度的所有内容都使用 aFrameworkElement来查找它。

对网络非常陌生,所以如果有一些简单的解决方案,我很抱歉询问。

Ver*_*rbe 5

In combination with TossNet to generate the .pdf file you can use Append.Blazor.Printing to show the print dialog.

The repository can be found here: https://github.com/Append-IT/Blazor.Printing

在此输入图像描述