Adobe Flash (SWF) to SVG and PDF

Recently, I found some documents exported as SWF. It would be certainly more convenient for me if I could read these documents in my PDF reader. So I needed a utility to convert content from Adobe Flash to PDF. For this reason, I’ve written a small Python program that utilizes the SWFTools in order to parse the SWF and exports output in SVG and PDF file formats.

You can download the utility from here: SWF to SVG/PDF. It is still very experimental and will certainly need some tuning in order to produce perfect output. In order to use it, you need, of course, Python and, also, the SWFTools. You need to add a few lines in lib/Makefile of SWFTools in order to create a dynamic library for Python:

librfxswf.$(SLEXT): $(rfxswf_objects) rfxswf.$(O) drawer.$(O) $(lame_in_source) $(h263_objects) $(as12compiler_in_source) $(as3compiler_objects) libbase$(A)
$(L) -g -shared $@ -o $^ -lz

The utility is split into two parts. The swf_lib.py uses Python ctype in order to communicate with the dynamic library and the swf_to_pdf.py is the main engine that performs the transformation. Currently shapes and text are supported. Eventually, more stuff could be implemented. It should be possible to transform a Flash application completely into an equivalent HTML5 application. I’ll leave that as an exercise for the reader!

You can see here an example of the utility:

  • The original PDF.
  • The SWF produced by SWFTools’ pdf2swf tool.
  • The output SVG produced by the SWF to SVG/PDF utility presented here.
  • The output PDF produced by the SWF to SVG/PDF utility presented here.
About these ads

13 Responses to “Adobe Flash (SWF) to SVG and PDF”

  1. Pat Coyne Says:

    Hi

    Very interesting post. I would like to convert static SWF files into SVG. I have used swftools but I’m afraid my knowledge of Python is non-existent. Is it possible to run your utility on Windows? if so how should it be installed and run?

    Regards

    Pat Coyne

    • prekageo Says:

      It should be possible to use it under Windows. I recommend installing Cygwin. Then you need to compile swftools and use the Python utility.

  2. rageahol Says:

    what version of swftools was this? there is a separate tool that is supposed to do something similar, gfx2gfx, but it’s not very helpful for my purposes.

    if you could give some tips on tuning this it would be helpful too, i keep getting upside down text, and am not sure how to troubleshoot that.

    • prekageo Says:

      Can you give an example of an SWF file that gives you upside down text? I guess you need to fine tune the transformation matrix.

  3. Anonymous Says:

    how can i use it under linux?
    is it necessary to recompile swftools?

    • prekageo Says:

      Yes, it is necessary. You have to add the lines mentioned in the Makefile in order to build a library that exposes the functionality of SWFTools.

  4. Mike Says:

    Hello! I tried adding that line you mentioned, but all that is produced during make is librfxswf.a; there is no librfxswf.dll. I am adding those two lines to lib/Makefile.in. What could I be doing wrong? (I am using SWFTools 0.6.2). Cheers :)

  5. Francisco Espinoza Says:

    An excellent tool, looking at the examples you have posted. I am interested in spending many swf files to pdf format. I would like you to give some more details about the installation and use, for newbies like me if possible. Please, I really urges me to use your tool, so far had only managed to convert swf to png.

    • prekageo Says:

      You must first install Python and then the SWFTools. Then you must change a little bit the Makefile and compile SWFTools. If you find any problem, you can ask here for clarifications.

  6. Francisco Espinoza Says:

    Please, tell me what I do it wrong (Im using Ubuntu 13.10):

    pacoesni@ubuntu:~/Downloads/swf_to_svg_pdf$ python swf_to_pdf.py
    Traceback (most recent call last):
    File “swf_to_pdf.py”, line 18, in
    s = swf_lib.SWF()
    File “/home/pacoesni/Downloads/swf_to_svg_pdf/swf_lib.py”, line 218, in __init__
    self.lib = cdll.LoadLibrary(LIB_PATH)
    File “/usr/lib/python2.7/ctypes/__init__.py”, line 443, in LoadLibrary
    return self._dlltype(name)
    File “/usr/lib/python2.7/ctypes/__init__.py”, line 365, in __init__
    self._handle = _dlopen(self._name, mode)
    OSError: librfxswf.dll: cannot open shared object file: No such file or directory
    pacoesni@ubuntu:~/Downloads/swf_to_svg_pdf$

    • prekageo Says:

      Since you are using Linux you must change the .DLL extension to .so and ensure that you have built the file librfxswf.so.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: