Skip to main content
Skip table of contents

pdfHTML: Bézier Curve Improvements

Background:

With the 7.1.16 release of iText Core and 3.0.5 of pdfHTML have come some improvements to how Bézier curves are calculated and displayed within PDF documents.

The screenshot below shows some HTML + CSS that utilizes Bézier curves. As we can see, the left and right sides of the shapes are evenly rounded.

The following is the output generated with pdfHTML version 3.0.4. Here, we can see that the edges of the Bézier curves are less round than anticipated, representing pdfHTML's prior lack of Bezier curve support.

Conversely, with pdfHTML 3.0.5, we see that the Bézier curves of both shapes more closely resemble that of the source HTML. 

.

You can test this for yourself using the example resources and code snippet below: 

Code Snippet:

JAVA:

java

JAVA
import java.io.File;
import java.io.IOException;
import com.itextpdf.html2pdf.HtmlConverter;

public class HtmlToPDFExample {

    public static final String DEST = "output_file_path/output_pdf.pdf";
    public static final String SRC = "input_file_path/input_html.html";

    public static void main(String[] args) throws IOException
    {
        File file = new File(DEST);
        file.getParentFile().mkdirs();
        new HtmlToPDFExample().createPdf(SRC, DEST);
    }

    public void createPdf(String src, String dest) throws IOException
    {
        HtmlConverter.convertToPdf(new File(src), new File(dest));
    }
}

C#:

C#

C#
using System;
using System.IO;
using iText.Html2Pdf;

namespace Example
{
    public class HtmlToPDFExample
    {

        public const String DEST = "output_file_path/output_pdf.pdf";
        public const String HTML = "input_file_path/input_html.html";

        public static void Main(String[] args)
        {
            FileInfo file = new FileInfo(DEST);
            file.Directory().Create();
            new HtmlToPDFExample().CreatePdf();
        }

        public virtual void CreatePdf()
        {
            HtmlConverter.ConvertToPdf(new FileStream(HTML, FileMode.Open), new FileStream(DEST, FileMode.Create));
        }
    }
}

Resources:

Right-click the link below and select "Save link as..." to download

border-radius.zip

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.