Jay Raj Mishra
Jay Raj Mishra

Reputation: 140

Image and Default background colour not rendring in SelectPdf in .net Core 5

The Image is not be render as giving the external base url in the SelectPdf Library in the .net core 5

enter image description here

    [HttpGet()]
    public IActionResult GetDocket()
    {
        HtmlToPdf htmlToPdf = new HtmlToPdf();
        htmlToPdf.Options.PdfPageOrientation = PdfPageOrientation.Portrait;
        htmlToPdf.Options.PdfPageSize = PdfPageSize.A4;
        htmlToPdf.Options.CssMediaType = HtmlToPdfCssMediaType.Print;
        htmlToPdf.Options.InternalLinksEnabled = true;
        htmlToPdf.Options.ExternalLinksEnabled = true;

        string html = "";
        html += "<div style='background-colour:#edf3f3'>";
        html += "<img src='/images/logo.svg' alt='BaseURLHomeLogo'";
        html += "</div>";

        PdfDocument pdfDocument = htmlToPdf.ConvertHtmlString(html, "https://xyz.home.com");
        byte[] pdf = pdfDocument.Save();
        return new FileContentResult(pdf, "application/octet-stream")
        {
            FileDownloadName = "Print.pdf"
        };
    }

Is there any options to set the background default color to #edf3f3, It is showing the white space after the content is over.

enter image description here

Upvotes: 0

Views: 791

Answers (1)

Jay Raj Mishra
Jay Raj Mishra

Reputation: 140

I have switched to another plugin. Explored with WkHtmlToPdf-DotNet, Now it is working well.

https://github.com/HakanL/WkHtmlToPdf-DotNet

SelectPdf was just time waster.

Upvotes: 0

Related Questions