How to Display a PDF in a Browser
When I first looked into this a couple of weeks ago I thought I could just use the browser’s native PDF rendering and then use scripting to control scrolling etc… but the browsers don’t really expose the ability to do this which is really a requirement because there’s not much point showing a PDF file if you can’t scroll it using MIDI control through Cantabile.
I looked into a couple of options for browser-based rendering of PDF files, but they were complex and cumbersome. Instead, I thought I’d try having cantabile-media-server render individual pages of the PDF to an image and have the browser display them as a series of images.
Demo
This afternoon I did some experimentation, and it seems to work pretty well. In this demo you can see
- On the left: Acrobat Reader showing the original file.
- On the right: browser showing single pages as rendered by the server (using ghost script)
Comparing the two I can’t see any noticeable or even significant differences. (If you’ve got a particularly unusual, complex or different type of PDF you would like to use let me know and I’ll test it out).
Next
- Per page e-tag caching so the pdf doesn’t need to be rendered each time the browser shows it, (ie: browser side caching)
- Setup something that can render multiple pages to look like a document