html-pdf converter: Images placed inside options header are not rendering in pdf
See original GitHub issueI am using html-pdf( v2.1.0) to convert and generate report in pdf format. I tried to have common header in all the pages using header option provide in the plugin by setting the base path like below.
var base = 'file://' + __dirname + '/logos/';
Printing base path
file:///Users/Documents/Sample Project/Code/Web Services/api/logos/
"header": {
"height": "25mm",
// "contents": "<img height='100' width='100' src='ACL.png'>"
"contents": "<P ALIGN=CENTER STYLE='margin-top: 0.04in; margin-bottom: 0.46in'><B>ACL Report</B><IMG SRC='SUN.png' ALIGN=LEFT HSPACE=12 WIDTH=113 HEIGHT=41 BORDER=0><IMG SRC='AAL.png' ALIGN=RIGHT HSPACE=12 WIDTH=135 HEIGHT=33 BORDER=0></P>"
}
Please help if anyone have faced the same issue.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6
Top Results From Across the Web
Add image in header using html-pdf node module
It is possible to add the image in options header. 1.Load the image in html body with "display:none" style. 2.Then add the image...
Read more >Headers and Footers with SelectPdf HtmlToPdf Converter
Select.Pdf Html To Pdf Converter can add headers and footers to the generated pdf document using the P:SelectPdf.HtmlToPdf.Header and P:SelectPdf.HtmlToPdf.
Read more >FAQ about ExpertPDF - .NET converter from HTML to PDF ...
Q: In rendered PDF document the images and text fonts appear to be smaller ... For other HTML documents the rendered content is...
Read more >Converting HTML to PDF with Blink engine | Syncfusion
Learn how to convert HTML to PDF using Blink rendering engine with various ... There is also no need to set BlinkPath to...
Read more >NReco.PdfGenerator: convert HTML to PDF in C#/.NET (FREE)
Popular C# wrapper for wkhtmltopdf with simple HTML to PDF API. Supports CSS/JS, custom fonts, page header/footer. Easy deployment (all-in-one DLL).
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I was able to get it working doing the following:
It’s important that both img tags have the absolute file path. Or else it did not work for me. I used
process.cwd()
since the absolute paths will be different between my local build and the server I deploy my work to (two different environments, therefore different locations). So it was important to get that path dynamically.You must also add the image in your html body like below: