JsReport in Docker not display footer

我的未来我决定 提交于 2021-02-08 11:56:22

问题


I'm using JsReport on .net Core 2.1

As I uploaded it to Azure, it needed to run separately in a Docker container. https://jsreport.net/learn/dotnet-local#azure-web-apps

however the Footer that showed the pages no longer works.

<div>Page<span class="pageNumber"></span>&nbsp;of&nbsp;<span class="totalPages"></span></div>

From what I saw, I need to configure this on the server (JsReport Studio), but in this case I just want the footer, since I couldn't store the skeleton of the page, etc.

Is there any solution?

Everything else works wonderfully, but something essential for me is the number of pages. If there is any other way to get around this limitation.


回答1:


The native chrome header/footer documentation is here https://jsreport.net/learn/chrome-pdf#native-headers-and-footers

Translated into c# asp.net core controller it should look like this. You need to make sure there is a space for the footer with a margin. And also set an explicit font size because of the chrome scaling issue mentioned in the docs.

[MiddlewareFilter(typeof(JsReportPipeline))]
public IActionResult Invoice()
{
    HttpContext
        .JsReportFeature()
        .Recipe(Recipe.ChromePdf)
        .Configure(cfg =>
        {
            cfg.Template.Chrome = new Chrome
            {
                DisplayHeaderFooter = true,
                MarginBottom = "2cm",
                FooterTemplate = "<div style='font-size: 20px; '>Page<span class='pageNumber'></span>&nbsp;of&nbsp;<span class='totalPages'></span></div>"
            };
        });

    return View(InvoiceModel.Example());
}


来源:https://stackoverflow.com/questions/63141951/jsreport-in-docker-not-display-footer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!