)
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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to avoid text and image splitting when converting HTML to PDF

Platform: WinForms |
Control: PDF |
Published Date: January 28, 2016 |
Last Revised Date: July 7, 2020
Tags: pdf, htmltopdf

The Syncfusion HTML to PDF for .NET is used for converting webpages, SVG, MHTML, and HTML to PDF. Using this library, you can avoid text and image splitting across the PDF pages while converting HTML to PDF.

Steps to avoid text and image splitting on HTML to PDF conversion:

  1. Create a new C# Windows Forms application project.

Create a windows form project

  1. Install the Syncfusion.HtmlToPdfConverter.QtWebKit.WinForms NuGet package as a reference to your .NET Framework application from NuGet.org.

install nuget packages

  1. Copy the QtBinaries folder from the HtmltoPdfConverter NuGet package installed location to the project folder that contains the HTMLtoPDF_Sample.csproj file.

copy the qtbinaries folder

paste the qtbinaries folder to project location.

 

  1. Disable the SplitTextLines and SplitImages properties available in the WebKitConverterSettings instance to avoid the text and image splitting during the HTML to PDF conversion. Find the sample and code sample as follows.

C#

//Initialize the HTML to PDF converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
 
//Initialize WebKitConverterSetttings
WebKitConverterSettings settings = new WebKitConverterSettings();
 
//Set WebKit path
settings.WebKitPath = @"/QtBinaries/";
 
//Set the SplitTextLines property
settings.SplitTextLines = false;
 
//Set the SplitImages property
settings.SplitImages = false;
 
//Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = settings;
 
//Convert URL to PDF
PdfDocument document = htmlConverter.Convert("input.html");
 
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
 

 

 

Screenshot of the SplitTextLines and SplitImages property enabled

documentenable output

 

Screenshot of the SplitTextLines and SplitImages property disabled document

                  disable output

A complete working sample can be downloaded from the HTMLtoPDF_Sample.zip

Take a moment to peruse the documentation for Converting HTML to PDF. You will find various options for URL to PDF, HTML string to PDF, and hyperlinks.

Refer to here to explore the rich set of Syncfusion Essential PDF features.

An online sample link for Converting HTML to PDF.

 

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
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
Live Chat Icon