Skip to content

Instantly share code, notes, and snippets.

@bryanwillis
Forked from mems/gist:5301297
Created December 9, 2013 19:18
Show Gist options
  • Select an option

  • Save bryanwillis/7879099 to your computer and use it in GitHub Desktop.

Select an option

Save bryanwillis/7879099 to your computer and use it in GitHub Desktop.

Convert (simple) SWF to PDF

In SWFTools a programs called gfx2gfx is available to do this task, but it's not officially available precompiled.

It can convert SWF, PDF or image to SWF, PDF, ebook or image.

Requirements

To use it, you need pdflib with downloadable sources or installable via macport sudo port install pdflib.

Create a file prepare.sh, copy following code, set as executable (chmod +x prepare.sh) and execute it (./prepare.sh) :

#!/bin/bash

# Create working folder and download sources
mkdir swftools
cd swftools
# Git is requiered here to download sources
git clone git://git.swftools.org/swftools .

# replace `../../swftools/` to `../` in sources
sed "s/..\/..\/swftools\//..\//g" src/gfx2gfx.c > src/gfx2gfx.c.tmp && mv src/gfx2gfx.c.tmp src/gfx2gfx.c

# On top of `Makefile.in` add `vpath = src` (will add `src` folder to sources folders)
echo "vpath = src" | cat - Makefile.in > Makefile.in.tmp && mv Makefile.in.tmp Makefile.in

./configure
make
cd src
make gfx2gfx

Usage

gfx2gfx file.swf -o file.pdf

Example : Non downloadable Slideshare slide show to PDF

This example use gfx2gfx to convert slides of slideshare slide show to PDFs

It use this slide show

View source of HTML, and find:

  • ID: like "doc":"xxx-xxx-phpapp0x" (just search "doc":)
  • slides count: like "slide_count":xx (just search "slide_count":)

Create a file download_convert.sh, copy following code and change the path of gfx2gfx tool and founded values

#!/bin/bash

# ID
doc="neumar2013final-130325115515-phpapp01"

# Number of slides
numSlides=51

# Path to gfx2gfx tool
gfx2gfx="/usr/local/bin/gfx2gfx"

echo "See also:"
echo "http://s3.amazonaws.com/slideshare/$doc.pdf"
echo "http://s3.amazonaws.com/ppt-download/$doc.pdf"
echo "http://s3.amazonaws.com/ppt-download/$doc.ppt"
echo "http://s3.amazonaws.com/slideshare/$doc.xml"

mkdir "$doc"
cd "$doc"

for (( slide=1; slide<=$numSlides; slide++ ))
do
	wget --no-check-certificate -O "slide-$slide.swf" "https://slideshare.s3.amazonaws.com/$doc-slide-$slide.swf"
	"$gfx2gfx" "slide-$slide.swf" -o "slide-$slide.pdf"
done

Notes

Based on:

See also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment