Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

PDF to HTML5 conversion – form names

48 sec read

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?



Do you need to solve any of these problems?

Use PDF Forms in the Web Browser
Integrate PDF Forms into Web Apps
Convert PDF forms to HTML5
Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

Leave a Reply

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

IDRsolutions Ltd 2022. All rights reserved.