In June, Andreas Gal (Andreas Gal) and colleagues from Mozilla presented the
pdf.js engine for displaying PDF using HTML5 / JavaScript. In the original version, it worked imperfectly, but the developers seriously got down to business and literally added functionality every day: graphics rendering, GUI, etc. But the most important thing is that TrueType fonts are dynamically loaded and PostScript Type 1 fonts are improved dramatically.
As a result, now Andreas Gal decided that the first test was passed and pdf.js pixel by pixel exactly * displays the
test document (
demo ).
Now pdf.js has been assigned the version number 0.2 and a new task has been set: to render the
official specifications PDF 1.7 (the document contains 1310 pages, a 31 MB file).
')
* In fact, the “perfect” rendering is achieved only in the build of Firefox Nightly under Windows 7 (with font rendering via Direct2D and DirectWrite), in the rest - close to ideal or not very close, depending on the browser and OS.Each pair of screenshots shows a comparison of the previous version of pdf.js (above) and pdf.js v0.2.

Andreas Gal says that the difference in the screenshots at the top should have been much more noticeable, but they did not dare to roll out the original version of pdf.js until they have done normal loading of PostScript Type 1 for the main font of the document in order to focus on the remaining problems. Dynamic loading Type 1 proved to be an extremely difficult task. It is difficult to overestimate how important this feature is for pdf.js.

The second pair of screenshots show some improvements in pdf.js. The most obvious is that the inscriptions on the image objects appeared due to the fact that v0.2 correctly loads TrueType fonts. The shadows behind the elements are recognized and displayed as background images. Dotted lines are rendered using the new APIs that have been added to the processing of the
canvas element by the Firefox browser, now they are in the process of standardization.

A screenshot with a monospace font is another proof of how important it was to make the most accurate measurement and loading of Type 1 fonts.

The color graphs in the diagram are rendered by separate JS functions, which then transfer pixel values ​​to the
canvas . These specific columns are calculated by the function of linear gradients. The text in the caption of the diagram also began to look better - as already mentioned, pdf.js learned to recognize and download different fonts.

The comparison above shows a couple of new v0.2 features. Signatures on the diagram appeared due to the loading of TrueType fonts, and the stroke fill of columns appeared due to the implementation of the function for the corresponding patterns.

Well, the last comparison shows improvements in the GUI, including a cool preview function - the panel pops up when you hover the mouse. In addition, in the lower screenshot, you can see a piece of the second page, whereas earlier pdf.js could only show one page at a time.
Andreas Gal thanks all the
independent developers who have joined the project and are helping the Mozilla team. For example, the new UI with the preview function is implemented
justindarc . Others have made support for encrypted PDFs, embedded JPEGs, Web Workers backends and others, which will be included in the functionality of the next version of pdf.js. In particular, when rendering 1310-page specifications, Web Workers will be needed to parallelize processes and the ability to suspend client-side computing in the main thread (UI responsiveness).
The developers believe that within two or 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 well. In the future, you can expect pdf.js to become the native part of the Firefox browser (release the extension first).
The authors of the project also hope that other browsers will follow their example and will implement pdf.js support, the code of which is published under a free license (modified by BSD). In the future, it will work equally well in any browser with HTML5 support.
Now this is not the case: almost every combination of browser / OS produces different results. Such is the fate of each project, which is done on the cutting edge of technology in the field of unapproved standards. According to Andreas Gala, now pdf.js comes to that stage when a significant part of the questions in reality are
bugs - the
engine -
browser rendering or
missing features , but these holes are gradually filled.