rdvojmoc / DinkToPdf

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

Small contents in PDF #133

Open aram-aramyan opened 3 years ago

aram-aramyan commented 3 years ago

Platform: Windows 10 x64 Paper size is 100m x 50 mm ~= 3.97in x 1.97in

The page contains an image with style="width: 98mm". The resulting PDF shows ~20% smaller image. theimage

When I set img style="width: 120mm" then I get almost what I need.

I've tried removing everything and just drawing some hr style="width: 100mm" ... hr style="width: 130mm". In that case only 130mm comes to look like it should be.

var doc = new HtmlToPdfDocument()
            {
                GlobalSettings =
                {
                    ColorMode = ColorMode.Grayscale,
                    PaperSize = new PechkinPaperSize("3.97in", "1.97in"),
                    Margins = new MarginSettings(0,0,0,0),
                    Out = filePath
                },
                Objects = {
                    new ObjectSettings() {
                        HtmlContent = htmlContents,
                        WebSettings = { DefaultEncoding = "utf-8" }
                    }
                }
            };

            _converter.Convert(doc);

Found this: https://github.com/rdvojmoc/DinkToPdf/issues/42 Tried adjusting Dpi to 380/600 Nothing changed

TropinAlexey commented 2 years ago

You can play with ObjectSettings.LoadSettings.ZoomFactor setting

DmitrySikorsky commented 1 year ago

You can play with ObjectSettings.LoadSettings.ZoomFactor setting

That worked for me (1.25).