Mozilla’s standards based PDF reader

Company aims to support all browsers using HTML5 and JavaScript


Firefox could natively render most PDFs online soon

Andreas Gal, researcher at Mozilla, has revealed Mozilla is working on a web-standards-based PDF reader, pdf.js (see Github for the latest code). He told .net that the idea was born on a recent business trip to Asia. "Chris Jones and I were discussing what platform capabilities might be missing from HTML5. We were wondering why Google Chrome embedded a native code PDF renderer to display PDFs and why nobody had implemented a PDF reader in HTML5/JavaScript yet," he recalls. "If you can do anything you want with HTML5, why would you have to use native code? We wanted to see whether doing this in JavaScript and HTML5 resulted in competitive performance and visual quality."

The main challenge was that PDF is a substantial specification. Gal says he and Jones were warned it could take a substantial time investment before they could get anything to render. "Fortunately, this turned out to be a less severe issue than we thought," says Gal. "HTML5 offers great high-level APIs for graphics and text rendering, so we didn't have to deal with any of those low-level problems, which greatly reduced what we had to implement. We already render a substantial subset of PDF, and our codebase is still below 5000 lines of code."

Short-term, Gal's blog post suggests the aim is to use pdf.js to render PDFs 'natively' within Firefox, but longer term aims are for a more open approach. "We are targeting HTML5, and any modern browser that supports it. As of today, [pdf.js] works in Firefox and Chrome," he says, adding that Safari and IE9 "both seem to be missing WebGL typed arrays at the moment". Gal hopes they'll catch up with the spec, otherwise a slower workaround might have to be devised for them.