In my web application, to export the HTML report to pdf I have used html2pdf.
Here in the HTML report, there is a logo.
But when it comes to the pdf all the data are shown as the view but the logo doesn't include in the pdf.
Is there any way of fixing this?
This is view
<div class="row" align="center" id="divToExport">
<table style="width:100%" class="table-responsive">
<tbody>
<tr>
<td colspan="2" align="center" class="auto-style1"></td>
</tr>
<tr align="right">
<td colspan="2" align="RIGHT">
<span id="DatetimeLBL" style="color:Black;font-size:12px;font-weight:normal;">@DateTime.Now</span>
</td>
</tr>
<tr align="center">
<td colspan="2" align="center">
<img src="https://i.imgur.com/mPF8.png" width="150" align="center">
</td>
</tr>
<tr align="center">
<td colspan="2">
<br>
</td>
</tr>
<tr align="right">
<td class="auto-style2"> Data di Nascita: </td>
<td align="left" class="auto-style2">
<span id="DOBLBL2" style="color:Black;">@Model.First().Date_Of_Birth_Fixed</span>
</td>
</tr>
<tr align="right">
<td> Nazionalità: </td>
<td align="left">
<span id="NationalityLBL2" style="color:Black;">@Model.First().Birth_Country</span>
</td>
</tr>
</tbody>
</table>
This is the javascript
function downloadItalyDoc() {
var element = document.getElementById('divToExport');
var opt = {
margin: 0.1,
filename: 'File.pdf',
image: { type: 'jpeg', quality: 2 },
html2canvas: { scale: 3, logging: true },
jsPDF: { unit: 'in', format: 'a4', orientation: 'portrait' }
};
}
https://stackoverflow.com/questions/72112887/image-from-a-link-not-showing-in-html2pdf as per this answer directly rendering image using (path) is not possible to export you need to render image by giving with base64 file binary data to export