ChromePDF images not showing in footer or header
-
I am having trouble getting images to show in the headers and footers on my pdf. There is strange behavior though. Here is my code for creating the report:
var rs = new LocalReporting().UseBinary(JsReportBinary.GetBinary()).AsUtility().Create(); Template template = new Template() { Recipe = Recipe.ChromePdf, Engine = Engine.None, Content = this.RenderViewToString("Overview", GetOverviewModel()), Chrome = new Chrome { Landscape = true, Format = "A4", MediaType = MediaType.Screen, MarginBottom = "80px", MarginLeft = "10px", MarginRight = "10px", MarginTop = "10px", Scale ="0.8", FooterTemplate = this.RenderViewToString("_FooterPartial", new { }), HeaderTemplate = "", DisplayHeaderFooter = true, PrintBackground = true } }; var rpt = await rs.RenderAsync(new RenderRequest() { Template = template });
Here is the footer partial page. I am using the entire path to link the image. When I navigate to the link directly the image shows fine.
@using mmars.Models <table style="margin-left:85%"> <tr> <td class="text-center"> <p style="font-size:11px; margin:0px">Powered by:<br /></p> </td> <td class="text-center"> <img src="http://localhost:1411/Graphics/MMcube.png" style="width:40px;height:40px;" /> </td> </tr> </table>
The strange behavior is that the footer on the first page does not even recognize the image, and then on subsequent pages, sees that there is an img but it cannot load it:
Any ideas on what might be causing this? Even when I put the html directly into the FooterTemplate string instead of calling RenderViewToString, I get the same behavior.
-
This is documented here
https://jsreport.net/learn/chrome-pdf#native-headers-and-footersYou need to use base64 for the chrome native header images.
-
@jan_blaha are there any examples of how to actually use this with .netcore pacakge?