最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - QuestPDF - Repeat content on every page - Stack Overflow

programmeradmin1浏览0评论

Is it possible to using QuestPDF when generating PDFs to have some content repeat on new pages?

The scenario I have is I am looping over 2 collections (headings & items) and it can span across an unknown number of pages.

Here is how I am currently printing the document.

page.Content().Column(column =>
{
    column.Spacing(5);

    for (int i = 0; i < random.Next(1, 10); i++)
    {
        //How to repeat this heading if the below loop spans multiple pages?
        column.Item().Background(Colors.Red.Accent4).AlignLeft().Padding(2).Text($" Heading {i}");
        
        for (int j = 0; j < random.Next(1, 20); j++)
        {
            column.Item().Row(row =>
            {
                row.ConstantItem(100).Text(DateTime.Now.ToShortDateString());
                row.ConstantItem(100).Text($"{i}. ");
                row.RelativeItem().ShowEntire().Text($"Some long text that potientially wraps");
                row.ConstantItem(100).AlignRight().Text("ABC");
            });
        }
    }
});

What I want to achieve is to repeat the heading every time a new page is created so I can print "Heading {i} continued"

Is there a way to achieve this? I tried using a combination of page.Header() and ShowIf but the header doesn't seem to be hit the second time.

发布评论

评论列表(0)

  1. 暂无评论