rdvojmoc / DinkToPdf

C# .NET Core wrapper for wkhtmltopdf library that uses Webkit engine to convert HTML pages to PDF.
MIT License
1.09k stars 416 forks source link

Nearly transparent images on multiple page pdfs #163

Open kurtyoder opened 2 years ago

kurtyoder commented 2 years ago

My images render perfectly if the pdf is a single page. If the pdf is longer than that, they are so transparent, they are barely visible.

This occurs when my image source is a file location or a base 64 string. Exporting the html content string to an html file displays the image correctly so it isn't something in my html.

Here is my doc model:

HtmlToPdfDocument doc = new()
        {
            GlobalSettings =
            {
                ColorMode = ColorMode.Color,
                Orientation = Orientation.Portrait,
                PaperSize = PaperKind.Letter,
                Margins = new(15, 15, 15, 15),
                DPI = 300,
                ImageDPI = 900,

            },

            Objects =
            {
                new ObjectSettings()
                {
                    PagesCount = true,

                    HtmlContent = html,

                    WebSettings = {DefaultEncoding = "utf-8", EnableIntelligentShrinking = false},
                    HeaderSettings = {FontSize = 8, Right = "Page [page] of [toPage]", Left = header, Line = true, Spacing = 2.812}
                }
            }
        };
islam-nady commented 2 years ago

Any update for this problem ,I have the same problem cannot repeat the image in header of pages if i have more than one page @kurtyoder @gldraphael @rdvojmoc

aaguileraThub commented 2 years ago

This happen to me a time ago while using a component from syncfusion. It was a weird bug from the webkit engine. I had almos transparent images when the image element were the first thing in the PDF document. The workaround i used was to put a label (or other element that prints something on screen) and made it invisble by setting a font or background color to match the page background color.

you can try that, it may help you with your issue