A group at Mozilla is working on direct rendering of PDF documents using nothing but JavaScript and HTML5.
PDF can be thought of as the web's second document format - after HTML of course. However unlike HTML you need a plugin to render PDF in a web page. A group at Mozilla is working on direct rendering of PDF documents using nothing but JavaScript and HTML5. The JavaScript code reads the PDF and then obeys the Postscript instructions it contains to draw the document on a canvas element.
The project has been quietly generating code on github for about a month but now feels that it has reached a point where the world should take a look - pdf.js. As you might expect it is open source.
The team claims that its intention is not to elevate PDF to a first class document format but to integrate it into HTML as just another display format. At the moment to display a PDF you have to write some code that loads the file and calls a function to render it:
pdfDocument = new PDFDoc(new Stream(data));
You also need to add some buttons to move to different pages but apart from this the result is a standard HTML page and so can be navigated and printed using the browser controls - i.e. no custom, and possibly confusing, plug-in controls.
At the moment the team is attempting to render just one target document at the pixel perfect level. You can see their progress - which is impressive - at 2009 paper rendered using pdf.js which you can compare to the original at 2009 paper rendered using a plugin.
They estimate that in about three months they should have a JavaScript application that can render the majority of PDFs found on the web. While the app is currently packaged separately the plan is to have it built into a future version of Firefox.
This is just another example of JavaScript inheriting the earth as it, with the help of the HTML5 hype, continues to become the language of choice.
What I can't figure out is, if the JavaScript application is going to be built into Firefox, why not build some C++ code that does Postscript/PDF into Firefox and make it truly native to the browser?
Further reading
If you would like to be informed about new articles on I Programmer you can either follow us on Twitter or Facebook or you can subscribe to our weekly newsletter.
NIST Finalizes ‘Lightweight Cryptography’ Standard to Protect Small Devices
20/08/2025
The problem of security on small devices is a serious one so it is a good job we have the NIST on the case. Its latest effort is to point us in the direction of a new set of cryptographic functions wh [ ... ]
A World First For Humanoid Robots
17/08/2025
Held from 15 to 17 August, the inaugural World Humanoid Robot Games has taken place in Beijing. Over 500 robots came together to compete in sports like boxing, football and table tennis, per [ ... ]
- Oxlint Rust Powered Linter Reaches 1.0
- Amazon S3 Vectors Or PostgreSQL- Is This The End Of Specialized Vector Stores?
- Go 1.35 Adds Experimental Garbage Collector
- Grafana 12.1 Adds Monitoring Tool
- Node.js Adds Default Type Stripping
- AWS Open Sources Strands SDK
- Apache Flink Adds AI
- Prompt Engineering For Agentic Systems
- Hour Of AI With Funding From Microsoft Elevate
- System Initiative Releases AI Infrastructure Automation Platform
- Python Still Growing - 2024 Developer Survey Results
- .NET Aspire 9.4 Adds CLI Tool
- Robot Crabs Attacked By Real Crabs