EVO HTML to PDF Converter allows you to select in HTML the fields you want to be converted to PDF form fields using the data-pdf-form-field special attribute. The other HTML fields which were not explicitly selected will not be converted to PDF form fields.
Code Sample - Define in HTML the PDF Form Fields
C#
protected void convertToPdf() { // Get the server IP and port String serverIP = textBoxServerIP.Text; uint serverPort = uint.Parse(textBoxServerPort.Text); // Create a HTML to PDF converter object HtmlToPdfConverter htmlToPdfConverter = null; if (radioButtonUseTcpService.Checked) htmlToPdfConverter = new HtmlToPdfConverter(serverIP, serverPort); else htmlToPdfConverter = new HtmlToPdfConverter(true, textBoxWebServiceUrl.Text); // Set optional service password if (textBoxServicePassword.Text.Length > 0) htmlToPdfConverter.ServicePassword = textBoxServicePassword.Text; // Set license key received after purchase to use the converter in licensed mode // Leave it not set to use the converter in demo mode htmlToPdfConverter.LicenseKey = "4W9+bn19bn5ue2B+bn1/YH98YHd3d3c="; // Set an adddional delay in seconds to wait for JavaScript or AJAX calls after page load completed // Set this property to 0 if you don't need to wait for such asynchcronous operations to finish htmlToPdfConverter.ConversionDelay = 2; // Set the submit buttons style htmlToPdfConverter.PdfFormOptions.SubmitButtonStyle.BackColor = RgbColor.Beige; // Set the style of various types of text boxes htmlToPdfConverter.PdfFormOptions.TextBoxStyle.BackColor = RgbColor.AliceBlue; htmlToPdfConverter.PdfFormOptions.PasswordTextBoxStyle.BackColor = RgbColor.MistyRose; htmlToPdfConverter.PdfFormOptions.MultilineTextBoxStyle.BackColor = RgbColor.AliceBlue; // Set the radio buttons style htmlToPdfConverter.PdfFormOptions.RadioButtonsGroupStyle.BackColor = RgbColor.AntiqueWhite; // Set the checkboxes styles htmlToPdfConverter.PdfFormOptions.CheckBoxStyle.BackColor = RgbColor.AntiqueWhite; // set the drop down lists style htmlToPdfConverter.PdfFormOptions.ComboBoxStyle.BackColor = RgbColor.LightCyan; byte[] outPdfBuffer = null; if (convertHtmlRadioButton.Checked) { // Convert a HTML string to a PDF document with form fields string htmlWithForm = htmlFormTextBox.Text; outPdfBuffer = htmlToPdfConverter.ConvertHtml(htmlWithForm, String.Empty); } else { // Convert the HTML page to a PDF document with form fields string url = urlTextBox.Text; outPdfBuffer = htmlToPdfConverter.ConvertUrl(url); } }
HTML Form to Convert to a PDF Form
XML
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Select HTML Form Fields to Convert to PDF Form</title> </head> <body style="font-family: 'Times New Roman'; font-size: 14px"> <form name="inputForm" action="http://www.evopdf.com/pdf_forms_submit/" method="post"> <table> <tr> <td>First name:</td> <td style="width: 10px"></td> <td> <input data-pdf-form-field="true" type="text" name="firstname" value="Enter First Name"></td> </tr> <tr> <td>Last name:</td> <td style="width: 10px"></td> <td> <input data-pdf-form-field="true" type="text" name="lastname"></td> </tr> <tr> <td>Password:</td> <td style="width: 10px"></td> <td> <input data-pdf-form-field="true" type="password" name="password"></td> </tr> <tr> <td>Gender:</td> <td style="width: 10px"></td> <td> <input data-pdf-form-field="true" type="radio" name="gender" value="male" checked="checked">Male <input data-pdf-form-field="true" type="radio" name="gender" value="female">Female </td> </tr> <tr> <td>Vehicle:</td> <td style="width: 10px"></td> <td> <input type="checkbox" name="car" value="car" checked="checked">I have a car <input type="checkbox" name="bike" value="bike">I have a bike </td> </tr> <tr> <td>Vehicle Type:</td> <td style="width: 10px"></td> <td> <select> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="audi" selected="selected">Audi</option> <option value="opel">Opel</option> </select> </td> </tr> <tr> <td>Comments:</td> <td style="width: 10px"></td> <td> <textarea style="width: 250px; height: 75px">Enter your comments here: First comment line Second comment line</textarea></td> </tr> <tr> <td colspan="3" style="height: 10px"></td> </tr> <tr> <td colspan="3"> <input data-pdf-form-field="true" type="submit" name="submitButton" value="Submit"></td> </tr> </table> </form> </body> </html>