I am cleaning out my old code snippets to see what I can post on the new blog. Here is a sweet little Flash pageflip app based off some source from PageFlip v2.13 coded by [email protected].
About the code
If you did not already know, I work for an educational publisher. We have an online subscription-based site which is essentially most of our titles chopped up and indexed into small teaching units. Users pay a fee to have unlimited print capability. When we started the site, we were using PDF’s with an encryption plug-in. We want to allow our users the print capability (it is the backbone of the site) but we did not want them to store the files. We wanted them to use the site to “store” them, and we also did not want them distributing PDF’s. The plug-in works, but there are issues.
First off, the Mac version is a bit behind the Windows version. Since we deal with teachers and schools, we must have a Mac solution. The plug-in also only works with Adobe Reader. Since Mac come with Preview, users got confused about why they could see other PDF’s but not ours. Since Preview couldn’t use the plug-in, the users basically saw a bunch of blank pages since the PDF contents were never decrypted. Lastly, we used a Java based virtual page-flip viewer so users could see the contents of the file before downloading the PDF and printing. The major headache is the users had 3 pieces of software to install the get the full experience. Not good.
Since we were having so many issues with installations and third-party software (reader wouldn’t recognize the plug-in, but the manufacturer’s installer said it was installed, Reader version was too old, Reader’s browser plug-in stinks, etc.) Istarted to look to alternatives. We considered writing our own PDF viewer, but quickly scrapped that idea. Then I started to look at Flash Paper. This looked like a pretty good alternative, but since the Macromedia/Adobe merger, the product is now treated like an illegitimate child.
I found Scribd, a start-up based in SF,CA. They took Flash Paper and basically rewrote it and extended it. It is really a pretty sweet thing. There were a couple issues, however. First, they would not let us purchase the code or host content on our servers. We have over 10,000 units, and we weren’t really eager to let them go, let alone the time it would’ve taken to upload (my company had a T1 back then and it was slooooow). We tried to come to an agreement but they just wouldn’t budge. In retrospect, I think it had to do with there PDF to SWF system (based on SWF Tools) and the fact that the “viewer” is really pretty basic. I think if people could run this locally they’d see that the system isn’t really that complex. The service is free, however, so it’s not like we wouldn’t get our money’s worth, right? However, all that aside, we still had issues with some of our PDF’s and really slow load times. We couldn’t have that, so I had to look elsewhere.
At this time the Flash pageflip stuff was pretty new, and quite cool IMHO. I thought it’d be pretty slick to use something like that and make my own Flash viewer (to replace the Java solution) and also use the Flash printing capabilities. This would solve all our problems! So, I downloaded this code and got to work. The code was using static page references, so I got it working with the XML file to dynamically load images into the viewer. It has been a while, so I don’t recall where the original code ended and mine began. Beyond that, I am no Actionscript guru, so I just kinda futzed around to get what I needed.
In the end, however, this was not the solution we used. It turns out to get that fancy flip action requires multiple versions of each page (3 if I recall correctly) and I could not figure out how to optimize it. Other than that, Flash basically just sucks. There is no garbage collection that can be called. Flash just decides when it will GC. Also, Flash has the nice undocumented feature of consuming every last drop of resources from your PC. We deal with user’s that have older PC’s, and our tests could actually crash browsers and lock-up machines. Thanks, Adobe!
What you get
Included in the zip are 2 versions of the viewer. the 2nd has an improved zoom capability. I put them both in so you could choose which one you wanted, and to let you see the differences I implemented regarding the zoom.
If you keep the number of pages small, or even keep them pretty low res, this will actually work okay. Did I mention you can also print? Oh, well, yeah, you can also print. All in all it is pretty groovy, but it just did not work out.
- Zoom capability
- Print entire “document”
- Dynamic page loading
- Ability to add custom logo to viewer
I hope someone out there finds a use for this. Enjoy!