Skip to main content
Skip table of contents

Can I convert an HTML form to a PDF?

There is limited support for converting HTML forms to a PDF document. If you have an HTML file with text fields that you want to convert to PDF, you also have to indicate whether you want the resulting PDF to be an interactive form.

Let's take a look at the form.html HTML file:

A simple HTML form

A simple HTML form

If we want to convert this HTML form to a PDF form (based on AcroForm technology), we need to mention this explicitly in the ConverterProperties (Java/.NET). See the C07E10_HelloAcroForm (Java/.NET) example:

JAVA
public void createPdf(String src, String dest) throws IOException {
    ConverterProperties properties = new ConverterProperties();
    properties.setCreateAcroForm(true);
    HtmlConverter.convertToPdf(new File(src), new File(dest), properties);
}

public void CreatePdf(String src, String dest)
{
    ConverterProperties properties = new ConverterProperties();
    properties.SetCreateAcroForm(true);
    HtmlConverter.ConvertToPdf(new FileStream(src, FileMode.Open, FileAccess.Read),
        new FileStream(dest, FileMode.Create, FileAccess.Write), properties);
}

Because of the line properties.setCreateAcroForm(true)/ properties.SetCreateAcroForm(true), an interactive PDF form is created. We can manually change the text in the fields with the blue background:

A simple PDF form

A simple PDF form

If we don't change the ConverterProperties (Java/.NET), as is the case in the C07E11_HelloFormFlattened (Java/.NET) example, we will get a "flat" PDF:

A flattened form

A flattened form

The content of the fields is there, but there is no interactivity in the file. The content of what once were HTML fields can't be changed in a PDF viewer.

Using interactive PDF forms for the purpose of manual data entry is somewhat outdated. When a form is to be filled out manually, HTML 5 is usually preferred.

JavaScript errors detected

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

If this problem persists, please contact our support.