问题
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> of <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> of <span class='totalPages'></span></div>"
};
});
return View(InvoiceModel.Example());
}
来源:https://stackoverflow.com/questions/63141951/jsreport-in-docker-not-display-footer