HiQPdf Documentation

Create Fillable PDF Forms from HTML Forms

Quickly Create High Quality PDFs

The converter can be configured to automatically create PDF forms that you can fill and submit from HTML forms using the PdfDocumentControlAutoPdfForm property of the HiQPdfAutoPdfForm type. A reference to an object of HiQPdf.PdfDocumentControl type is given by the Document property of the HiQPdf.HtmlToPdf class.

In order to enable the translation of HTML forms to PDF forms you have to set AutoPdfFormAutoCreatePdfForm property on true.

HTML Document Containing the HTML Form to Convert to a PDF Form

XML
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Auto Create PDF Forms from HTML Forms</title>
</head>
<body style="font-family: 'Times New Roman'; font-size: 14px">
    <form name="subscrForm" action="http://www.hiqpdf.com/formsubmitaction/" method="post">
        Name:<br />
        <input style="width: 200px" type="text" name="subscrName">
        <br />
        <br />
        Email :<br />
        <input style="width: 200px" type="text" name="subscrEmail"><br />
        <br />
        Website:<br />
        <input style="width: 200px" type="text" name="subscrWebsite"><br />
        <br />
        Password:<br />
        <input style="width: 200px" type="password" name="subscrPassword"><br />
        <br />
        Gender:&nbsp;
        <input type="radio" name="subscrGender" value="male" checked="checked">Male
        <input type="radio" name="subscrGender" value="female">Female<br />
        <br />
        Domains of interest:&nbsp;
        <select name="subscrDomains">
            <option value="science" selected="selected">Science</option>
            <option value="culture">Culture</option>
            <option value="music">Music</option>
        </select><br />
        <br />
        Newsletter:&nbsp;<input type="checkbox" name="receiveNewsletterEmail" value="email" checked="checked">By email
                    <input type="checkbox" name="receiveNewsletterPost" value="post">By post
        <br />
        <br />
        Short description:<br />
        <textarea name="subscrDescription" style="width: 300px; height: 100px"></textarea>
        <br />
        <br />
        <input type="submit" name="submitButton" value="Submit Form">
    </form>
</body>
</html>
Auto Create PDF Forms Demo

In this demo you learn how to automatically create a PDF form from a HTML form. You can fill and submit the generated PDF form.

Demo Source Code

C#
protected void buttonCreatePdf_Click(object sender, EventArgs e)
{
    // create the HTML to PDF converter
    HtmlToPdf htmlToPdfConverter = new HtmlToPdf();

    htmlToPdfConverter.BrowserWidth = 800;

    // automatically create a PDF form from HTML form
    htmlToPdfConverter.Document.AutoPdfForm.AutoCreatePdfForm = checkBoxCreateForm.Checked;

    // convert the HTML code to PDF
    byte[] pdfBuffer = htmlToPdfConverter.ConvertHtmlToMemory(textBoxHtmlCode.Text, null);

    // inform the browser about the binary data format
    HttpContext.Current.Response.AddHeader("Content-Type", "application/pdf");

    // let the browser know how to open the PDF document, attachment or inline, and the file name
    HttpContext.Current.Response.AddHeader("Content-Disposition", String.Format("attachment; filename=AutoPdfForms.pdf; size={0}",
                    pdfBuffer.Length.ToString()));

    // write the PDF buffer to HTTP response
    HttpContext.Current.Response.BinaryWrite(pdfBuffer);

    // call End() method of HTTP response to stop ASP.NET page processing
    HttpContext.Current.Response.End();
}
See Also

Other Resources