We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to resize the HTML content in PDF during WebKit HTML to PDF conversion

Platform: WinForms |
Control: PDF
Tags: htmltopdf, webkit

Adjusting HTML content size in PDF is possible by using WebKitViewPort property of WebKit HTML converter.

WebKitViewPort: WebKit viewport size will set to WebKit browser’s window size. If the viewport width is smaller than HTML content width, then WebKit HTML converter use HTML content width as viewport width. WebKit HTML converter automatically calculates the height of HTML based on the viewport width.

Default Viewport size: By default, WebKit HTML converter takes the viewport width of the machine where conversion takes place.

Assemblies Required

  1. Syncfusion.Compression.Base.dll
  2. Syncfusion.HtmlConverter.Base.dll
  3. Syncfusion.Pdf.Base.dll
  4. QtBinaries folder

All the above mentioned assemblies can be get by installing the WebKit installer available in the below link.

WebKit HTML Converter: https://www.syncfusion.com/downloads/latest-version

Code snippet:

// Create a HTML to PDF converter object with default settings

HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);

WebKitConverterSettings webKitSettings = new WebKitConverterSettings();


//Set page size

webKitSettings.PdfPageSize = new SizeF(512,692);


//Set WebKitpath

webKitSettings.WebKitPath = @"../../../../QtBinaries";


//Set WebKit Viewport

//changing height value will not make any difference in output PDF

webKitSettings.WebKitViewPort = new Size(800,0);


htmlConverter.ConverterSettings = webKitSettings;


//Convert url to pdf

PdfDocument document = htmlConverter.Convert("input.html"); 


//Save the document.



Please refer below screen shots of result with different WebKitViewPort size:



Default System ViewPort Size

Custom ViewPort Size

(800 width)


Please refer below Output PDF documents with different WebKitViewPort size,


Working Sample can be downloaded from the below link,


2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile