HakanL / WkHtmlToPdf-DotNet

C# .NET Core wrapper for wkhtmltopdf library that uses Webkit engine to convert HTML pages to PDF.
GNU Lesser General Public License v3.0
372 stars 67 forks source link

Pdf getting shrinked after conversion from HTML. #49

Closed koleys closed 3 years ago

koleys commented 3 years ago

I am facing this weird issue , where the HTML file after conversion to PDF is getting shrinked . As a result i am getting a PDF which is shrinked to the top left corner. Any pointers on how I can resolve the issue is appreciated.

HakanL commented 3 years ago

Since this is just a .NET wrapper around somebody else's native library I suggest you test it with the native library (command line) directly to understand where the problem is.

pedroter7 commented 1 year ago

I'm almost 2 years late but for those struggling with this issue this shrinking is due to a feature in WebKit called smart shrinking (or something like that). You can avoid it by setting EnableIntelligentShrinking = false in your WebSettings object inside the HtmlToPdfDocument. The equivalent command line argument to wkhtmltopdf is --disable-smart-shrinking.