DinkToPdf footer not working when there is an image

104 Views Asked by At

I'm using DinkToPdf library in a .NET 7 web application to create a pdf. However, when I include a pdf in the footer, it does not work.

This is the code for generating the pdf.

var html = await _templateEngine.RenderAsync("Views/CalibrationCertificate.cshtml", calibrationCertificate);

var basePath = AppContext.BaseDirectory;
var footerViewPath = Path.Combine(basePath, "Resources", "Footer.html");

var doc = new HtmlToPdfDocument()
{
    GlobalSettings = {
        PaperSize = PaperKind.A4,
        Orientation = Orientation.Portrait
    },
    Objects = {
        new ObjectSettings()
        {
            HtmlContent = html,
            FooterSettings = new()
            {
                HtmUrl = footerViewPath,
            }
        }
    }
};

var result = _htmlToPdfConverter.Convert(doc);

This is the contents of Footer.html.

<div class="hr mt-2 mb-5 page-break-avoid" />

<div class="row mt-2 page-break-avoid">
    <div class="col-4">
    </div>
    <div class="col-4 d-flex justify-content-center">

    </div>
    <div class="col-4">
        <img src='logo.jpg' />
    </div>
</div>

This is my folder structure. folder structure

This is the build properties of logo.jpg. build properties

Generated pdf file is empty (when downloaded using blazor client app). generated pdf

I'm new here, so please excuse if I have violated any guidelines.

I tried all the suggestions I could find in the internet.

0

There are 0 best solutions below