How to add image to header in DinkToPdf html to pdf converter in C#

671 Views Asked by At

public string GeneratePdfReport(string htmlTemplate, string path, string headerTemplate, string auditBy) {

        var globalSettings = new GlobalSettings
        {
            ColorMode = ColorMode.Color,
            Orientation = Orientation.Portrait,
            PaperSize = PaperKind.A4,
            Margins = new MarginSettings { Top = 20, Bottom = 20, Right = 10, Left = 10 },
            DocumentTitle = "PDF Report",
            Out = path
        };


        var objectSettings = new ObjectSettings
        {
            PagesCount = true,
            HtmlContent = htmlTemplate,
            WebSettings = { DefaultEncoding = "utf-8", PrintMediaType = true, LoadImages = true },
            HeaderSettings = { FontName = "Arial", FontSize = 9, Line = true, HtmUrl = @"C:\...\Uploads\CompanyLogo\Logo.htm" },
            FooterSettings = { FontName = "Arial", FontSize = 9, Line = true, Right = "Page [page]", Left = auditBy }
        };
        var pdf = new HtmlToPdfDocument()
        {
            GlobalSettings = globalSettings,
            Objects = { objectSettings }
        };

        _converter.Convert(pdf);

        return path;
    }

Specified path of html file in HtmUrl but image is not displaying in header Can anyone specify solution for that

0

There are 0 best solutions below