Replace Alfresco standard Flash viewer with pdf.js
jan 08 2012
Have you noticed that the flash based previews in Alfresco 4.0 looks a bit blurry? Then you are correct, it is not your vision that’s failing, they really are. This is due to change settings for pdf2swf program (that create the flash) to make it more reliable for large pdfs, and for certain pdfs it could crash the jvm completely. So there was a good reason for the change.The image above shows the difference between the settings. Details can be found in this issue ALF-10870. This issue is now closed as won’t fix, something I do not agree with. It would have been better to postpone the fix for 4.0.x (or any later version) if there is no immediate resolution, because a fix is needed, no one wants previews that makes Alfresco look like an inferior product (that it absolutely not is) on first impression.
But my intention here is not to whine, Alfresco has the bigger picture here, and has to set the priorities. And since this is an open source product, if you are not to happy with how something work, you can fix/enhance it. So that is what I’ve done. I’ve created an alternative viewer based on the Mozilla project pdf.js.
All documents that are shown in the flash based viewer has been transformed in the chain:
<source format> - <pdf> - <flash>
So the viewer I’ve implemented tries to
The easiest way to do this was to use <iframe>, where the pdf.js viewer is loaded via an Alfresco surf page that implements the standard viewer almost out of the box. You can try the standard one here. It is very feature complete, and handles most of the pdfs I’ve tried very well.
The same method, using iframe, is used to display using a pdf reader plugin, just call the pdf directly in the iframe src url.
I will release the source code shortly, needs to be cleaned up a bit. I will update here when I’m done with that.
The source code is checked into the Share Extras project. You can view it here.
There is no compiled release yet, that is on purpose, it is still untested, but if you know how to check-out and compile, then I assume you understand not to rush it to use on a production server.