Update: JPDF2HTM5 has been rebranded as BuildVu and JPDFForms has been rebranded as FormVu

PDF to HTML5 conversion – form names

When we create an HTML5  form from a PDF file we  have a choice of how we handle the form names. We can either use an autogenerated value, or we can use the name of the Form from the PDF. The second is much more useful because it makes it easy to compare the PDF and the HTML5. There is, however, a slight catch (isn’t there always!).

Characters which are allowed in the PDF form name are not valid in an HTML5 form name (space, ‘.’, etc). So we need to replace these in the HTML version (we use underscore so dodgy name.1 would become dodgy_name_1).This works fine but it stops us being able to easily use the name to identify the PDF form.

But, we can easily add additional attributes to the HTML. So, we add a new value (pdfFileName) which will be ignored by the HTML5 parser, but allow any user to easily identify the original PDF form field used. Here is an example.

<input type="text" tabindex="12" id="Geb-Datum" value=""  
pdfFieldName="Geb.Datum" />
<input type="text" tabindex="34" id="Ehepartner_AHV-Nr" value=""  
pdfFieldName="Ehepartner AHV-Nr" />

At the cost of making the HTML5 file slightly bigger we get the ability to identify easily between PDF and HTML form components. Would any other PDF file information be useful inside the HTML?

Click Here to see all the articles in the PDF to HTML5 conversion series.

Related Posts:

The following two tabs change content below.

Mark Stephens

System Architect and Lead Developer at IDRSolutions
Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX. He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.
Markee174

About Mark Stephens

Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX.

He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>