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 – choosing the best fontsize

35 sec read

One of the interesting ‘issues’ in writing a PDF to HTML5 convertor is choosing the correct fontsize. In theory this should be easy. If it is 8pt in the PDF we use that for the PDF.

So what happens if we have a value of 8.5pt? This is perfectly possible in PDF (where it can be any double value) but HTML5 only allows 8 or 9. In Maths you would round 8.5 but in HTML5 the answer is it depends… Neither is perfect and you are also limited by the fact that Word spacing and Char spacing are also more limited than in PDF.

You also need to consider any Word Spacing and Text Spacing. I’ve been adding some heuristics this week to improve this in some cases. It makes some definite improvements but it is early days. So if you have any particularly interesting layouts which you think could be improved, let us know.

This post is part of our “Fonts Articles Index” in these articles we explore Fonts.

IDRsolutions develop a Java PDF Viewer and SDK, an Adobe forms to HTML5 forms converter, a PDF to HTML5 converter and a Java ImageIO replacement. On the blog our team post anything interesting they learn about.

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.

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
2 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

Leave a Reply

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

IDRsolutions Ltd 2019. All rights reserved.