PDF2SWF : Auto conversion from PDF to SWF
I never thought I will be converting some PDF files into SWF anytime. But the time has come and I was doing the same for past some days. Well,while deciding for the tools and technology I always thought FlashPaper is a good option. Surprisingly for me FlashPaper is dead now ! In the beginning days I always asked myself why FlashPaper was created from Macromedia ?! But then situations come up,where one has to fall back to flash technology. Well, with the death of FlashPaper, I lost hope, then found Scribd. Awesome, they do the same thing online and have a rich set of API exposed for developers to do the same. Unfortunately, for security reasons my option only include softwares which can be used in-house.
Well, then I came across SWFTOOLS. An opensource library of tools for SWF. One of the tools is PDF2SWF. As the name suggests, it converts a complete PDF to SWF. It not only just converts PDF to SWF but also maintains all the links in the PDF in the generated SWF. Thats a pretty nice job. It has a GUI too for those who want to use it. Personally I found the command line of this tool to be awesome. There are a large number of options available while converting from PDF to SWF. By default once the SWF is created it starts running as a presentation in a default timer. There is an option to put “stop()” action in each frame(as each page becomes one frame),nice and sweat. The default conversion gives a nice default viewer to navigate to different pages,zoom in/out and scrollbars. One can customise the default viewer to make ones one viewer too.
The only thing which hurt me is the SWF produced in a AVM1 Movie,though SWFTOOLS says that the latest version produces AVM2 movies,but it is not. To make an AVM2 movie I just passed in the flashplayer version 10.0 in one of the command line options.That gave me an AVM2 movie. For my custom player, I just went ahead and loaded the movie with an “Loader” and since its AVM2,I typecast it to a “MovieClip” and then started controlling it through AS3.
I am expecting more from the tool and the first expectations is, it should produce an AVM2 movie. The method to add a viewer should be more easier.
Over all, the tools are just freaking cool. All the best to the SWFTOOLS. Hoping to see this project mature.
Lastly below are the options one will get while firing up PDF2SWF from command line. I have just copied the help from PDF2SWF from my command line to put it here.
Usage: pdf2swf [-options] file.pdf -o file.swf
-h , –help Print short help message and exit
-V , –version Print version info and exit
-o , –output file.swf Direct output to file.swf. If file.swf contains ‘%’ (file%.swf), then each page goes to a seperate file.
-p , –pages range Convert only pages in range with range e.g. 1-20 or 1,4,6,9-11 or
-P , –password password Use password for deciphering the pdf.
-v , –verbose Be verbose. Use more than one -v for greater effect.
-z , –zlib Use Flash 6 (MX) zlib compression.
-i , –ignore Allows pdf2swf to change the draw order of the pdf. This may make the generated
-j , –jpegquality quality Set quality of embedded jpeg pictures to quality. 0 is worst (small), 100 is best (big). (default:85)
-s , –set param=value Set a SWF encoder specific parameter. See pdf2swf -s help for more information.
-w , –samewindow When converting pdf hyperlinks, don’t make the links open a new window.
-t , –stop Insert a stop() command in each page.
-T , –flashversion num Set Flash Version in the SWF header to num.
-F , –fontdir directory Add directory to the font search path.
-b , –defaultviewer Link a standard viewer to the swf file.
-l , –defaultloader Link a standard preloader to the swf file which will be displayed while the main swf is loading.
-B , –viewer filename Link viewer filename to the swf file.
-L , –preloader filename Link preloader filename to the swf file.
-q , –quiet Suppress normal messages. Use -qq to suppress warnings, also.
-S , –shapes Don’t use SWF Fonts, but store everything as shape.
-f , –fonts Store full fonts in SWF. (Don’t reduce to used characters).
-G , –flatten Remove as many clip layers from file as possible.
-I , –info Don’t do actual conversion, just display a list of all pages in the PDF.
-Q , –maxtime n Abort conversion after n seconds. Only available on Unix.