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.
For discard downscaling for rasterized image (default: 72dpi) we use the provided by @m-p-y: add -r
attribute to increase maxdpi
To compile it, you need pdflib and patch
, with compilable sources (./configure && make && make install
) or install it directly via macport (OSX only) (sudo port install pdflib patch
).
For Linux you need to install SWFTools deps: sudo apt-get install libfontconfig1-dev libfftw3-dev libzzip-dev libpoppler-dev libjpeg62-dev libgif-dev libpng12-dev
. (see also)
Create a file make.sh
, copy following code, set as executable (chmod +x make.sh
) and execute it (./make.sh
) :
#!/bin/bash
# Git is required here to download sources
# Remove folder if exist
rm -rf ./swftools
git clone --depth=1 git://github.com/matthiaskramm/swftools ./swftools
cd swftools
# Apply patch by @m-p-y
patch -p1 -f -i - <<EOF
diff -ur a/Makefile.in b/Makefile.in
--- a/Makefile.in 2016-03-13 01:08:14.000000000 +0100
+++ b/Makefile.in 2016-03-13 01:09:13.000000000 +0100
@@ -1,3 +1,4 @@
+vpath = src
top_builddir = ..
srcdir = @srcdir@
top_srcdir = @top_srcdir@
diff -ur a/src/gfx2gfx.c b/src/gfx2gfx.c
--- a/src/gfx2gfx.c 2016-03-13 01:08:14.000000000 +0100
+++ b/src/gfx2gfx.c 2016-03-13 00:58:31.000000000 +0100
@@ -50,6 +50,7 @@
static char * outputname = 0;
static int loglevel = 3;
+static char * maxdpi = "72";
static char * pagerange = 0;
static char * filename = 0;
static const char * format = 0;
@@ -77,6 +78,11 @@
setConsoleLogging(loglevel);
return 0;
}
+ else if (!strcmp(name, "r"))
+ {
+ maxdpi = val;
+ return 1;
+ }
else if (name[0]=='p')
{
do {
@@ -110,7 +116,7 @@
}
else if (!strcmp(name, "V"))
{
- printf("pdf2swf - part of %s %s\n", PACKAGE, VERSION);
+ printf("gfx2gfx - part of %s %s\n", PACKAGE, VERSION);
exit(0);
}
else
@@ -126,6 +132,7 @@
{"q","quiet"},
{"V","version"},
{"s","set"},
+ {"r","resolution"},
{"p","pages"},
{0,0}
};
@@ -264,6 +271,7 @@
msg("<error> Invalid output format: %s", format);
exit(1);
}
+ out->setparameter(out, "maxdpi", maxdpi);
int pagenr;
for(pagenr = 1; pagenr <= doc->num_pages; pagenr++)
EOF
./configure
make
cd lib
make
cd ../src
make gfx2gfx
echo "gfx2gfx bin should be compiled in $(pwd)"
If you get the error Undefined symbols for architecture x86_64: "_gfxdevice_pdf_init"
, that means pdflib
is not installed
gfx2gfx file.swf -o file.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
(set it executable), 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" -p400 "slide-$slide.swf" -o "slide-$slide.pdf"
done
echo "Now you can merge all slides to one PDF!"
View source of HTML, and find:
- ID: like
"documentId":"xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
- slides count: like
"pageCount":xxx
Create a file download_convert.sh
(set it executable), copy following code and change the path of gfx2gfx
tool and founded values
#!/bin/bash
# ID
doc="090224121313-2f028222e017481ba99f3ba2800c8167"
# Number of slides
numSlides=11
# Path to gfx2gfx tool
gfx2gfx="/usr/local/bin/gfx2gfx"
echo "See also:"
echo "http://document.issuu.com/$doc/document.xml"
mkdir "$doc"
cd "$doc"
for (( slide=1; slide<=$numSlides; slide++ ))
do
wget --no-check-certificate -O "slide-$slide.swf" "https://page.issuu.com/$doc/swf/page_$slide.swf"
"$gfx2gfx" -p400 "slide-$slide.swf" -o "slide-$slide.pdf"
done
echo "Now you can merge all slides to one PDF!"
To merge separate PDF to one document, you can use "/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py" -o pages.pdf page*.pdf
(OSX only) or gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=pages.pdf page*.pdf
or convert of ImageMagic convert -compress jpeg -quality 90 page*.pdf pages.pdf
(but rasterise all pages) or pdftk
or pdfunite
or use pdfmerge
from PDFlib-Lite (exist in C, PHP, Java, etc.)...
Works on OSX 10.11.3
Based on:
- [Swftools-common] swf2pdf
- How-To: Download Author Disabled Presentations from SlideShare
- phil has a blog
- xml - Downloading most recent PDF in Issuu - Stack Overflow
See also
- Adobe Flash (SWF) to SVG and PDF | Prekageo's Blog
- swftools : Trusty (14.04) : Ubuntu
- swftools on Ubuntu 14.04 – Trusty Tahr | Toys for the desk!
- THE LINUX STUFF: Installing swftools and pdf2swf on Ubuntu Linux
Thanks for your usefull comments
Thank you for this.
I also needed to install g++ on Kubuntu 14.04 LTS (sudo apt-get install g++).
I also needed to run the "make" script twice (the first time, it stops before the end due to an error, the second it compiles it without problems).