📜 ⬆️ ⬇️

PDF rendering using HTML5 and JavaScript (pdf.js)

Andreas Gal (Andreas Gal) and colleagues from Mozilla developed the first normal pdf.js engine for displaying PDF using HTML5 / JavaScript ( demo ).

According to the developers, PDF rendering directly in the browser is much more convenient for the user, because he will not have to think about installing external PDF viewers, many of which, moreover, do not fully support the important PDF specifications and force them to learn the unusual interface (not the same as in the browser).

The introduction of native or open-source plug-ins into the browser is also not an ideal solution, because this is a potential security breach.

Development of pdf.js has been going on for more than a month, but only now the developers have decided to announce this to a wide audience. They first wanted to complete the main features (Type1 fonts, gradients, etc.) so that the engine could be used at least somehow. But a great surprise was the great interest of the community in this project, and you could not conceal the sewing in a bag, so you had to reveal the cards ahead of time.
')
The project plan is as follows. First, they want to bring pdf.js to a perfect (pixel-by-pixel indistinguishable) rendering on one test document: this is a scientific report describing the JavaScript compiler TraceMonkey . This document is displayed in the above demo . Of course, there are still a lot of glitches and rendering artifacts, but on the whole it is clear what this is about. Right now, they are finishing up support for Type1 PostScript fonts, so that soon the demo document will become much nicer in appearance.

Further it is planned to implement other PDF options via canvas and discuss how you can use JavaScript to implement the most complex PDF specifications for which there is no direct match in HTML Canvas .

The developers believe that within three months they will be able to bring pdf.js to such a level that it will be able to display most of the PDF documents on the web. In the future, you can expect pdf.js to become the native part of the Firefox browser (release the extension first).

The project authors also hope that other browsers will follow their example and implement pdf.js support, the code of which is published under a free license (modified by BSD).

Source: https://habr.com/ru/post/122034/


All Articles