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.

PDF to HTML5 conversion – Different behaviour on HTML5 tags in Firefox

51 sec read

We have just fixed an interesting little ‘feature‘ with Firefox and HTML5. In Firefox some of the HTML5 pages we generate from our PDF to HTML5 convertor were not appearing with the images on. We hunted this down and it turned out to be nothing to do with the images themselves but with the way FireFox handles an HTMLDivElement.

In Chrome/Safari you can pass the HTMLDivElement into a subroutine so we had this code in our HTML5 code.

setFontSize(t1,'12','140');

t1 is an entry in the Cascading Stylesheet which refers to a text element and setFontSize is a Javascript routine which adjusts the font size to make the text fit the correct space using whatever font is applied.

function setFontSize(el,pixelSize,actualWidth) {
 el.style.fontSize = pixelSize+'px';

It is neat, but it fails to work on Firefox because t1 has a value of null. So the rest of the code breaks. It works in Firefox if you do this.

setFontSize('t1','12','140');

t1 is now the name of the element (not the element itself), which we then lookup.

function setFontSize(divName,pixelSize,actualWidth) {
 var el = document.getElementById(divName);
 el.style.fontSize = pixelSize+'px';

All the images now work! Like Java, HTML5 is a world of write once, debug everywhere… Have you found any interesting HTML5 ‘features’?

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

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.

Converting your PDF files to HTML5 with BuildVu 

Recently we announced our updated product range for 2018 and are rebranding some existing products, like JPDF2HTML5 which has been renamed to BuildVu. It...
Georgia Ingham
3 min read

Favourite resources from our HTML development team

As the web progresses and grows, so do the technologies that come along with it. Trying to keep on top of everything you need...
Ovidijus Okinskas
1 min read

How HTML5 Javadocs in Java 9 will make your…

Here at IDRsolutions we are very excited about Java 9 and have written a series of articles explaining some of the main features. In...
Rob
1 min read

Leave a Reply

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