Difference between revisions of "Third-party software integration: SWFTools"

From OpenKM Documentation
Jump to: navigation, search
(Segmentation fault (core dumped) Conversion problem)
(Segmentation fault (core dumped))
Line 141: Line 141:
 
=== Segmentation fault (core dumped) ===
 
=== Segmentation fault (core dumped) ===
 
This is a log of segmentation fault error:
 
This is a log of segmentation fault error:
  /home/openkm/tomcat-7.0.27/bin/pdf2swf -f -T 9 -t -s storeallcharacters input.pdf -o output.swf
+
  /home/openkm/tomcat-7.0.27/bin/pdf2swf -f -T 9 -t -s bitmap -s storeallcharacters input.pdf -o output.swf
 
  NOTICE  processing PDF page 1 (878x1105:0:0) (move:0:0)
 
  NOTICE  processing PDF page 1 (878x1105:0:0) (move:0:0)
 
  NOTICE  File contains forms
 
  NOTICE  File contains forms

Revision as of 11:33, 2 May 2013

To enable preview UI tab, OpenKM need to convert pdf files to swf.


Nota advertencia.png Starting from OpenKM 5.1 this configuration property has changed to system.swftools.pdf2swf.


Nota clasica.png Since OpenKM 5.1.9 the pdf2swf command line parameters should be added in the configuration property, for example:
 system.swftools.pdf2swf=/usr/bin/pdf2swf -T 9 -f ${fileIn} -o ${fileOut}

See FlexPaper: Converting Documents for more info.

Linux

Ubuntu

Swftools can be installed running in terminal:

$ sudo aptitude install swftools

Enable in OpenKM.cfg or Administration > Configuration depending on your OpenKM version:

system.swftools.pdf2swf=/usr/bin/pdf2swf

Nota clasica.png In Ubuntu 10.04 is possible you need to add this line to /etc/apt/sources.list
deb http://archive.canonical.com/ubuntu lucid partner


Nota clasica.png In Ubuntu 10.10 this package is not included, so you need to compile it or grab from https://launchpad.net/~ella-animation/+archive/dev:
 $ sudo add-apt-repository ppa:ella-animation/dev
 $ sudo aptitude update
 $ sudo aptitude install swftools

Red hat

Better if you compile version 0.9.x

$ yum install zlib-devel libjpeg-devel giflib-devel freetype-devel gcc gcc-c++
$ wget http://www.swftools.org/swftools-0.9.1.tar.gz
$ tar xzf swftools-0.9.1.tar.gz
$ cd swftools-0.9.1
$ ./configure --prefix=/usr/local
$ make
$ make install 

Debian

This package is not include in the Debian repositories, so you need to compile from source:

$ aptitude install build-essential libgif-dev xpdf libfreetype6 libfreetype6-dev libjpeg62 libjpeg8 libjpeg8-dev 
$ wget http://www.swftools.org/swftools-0.9.1.tar.gz
$ tar xzf swftools-0.9.1.tar.gz
$ cd swftools-0.9.1
$ ./configure --prefix=/usr/local
$ make
$ make install 

Or you can try to install the Ubuntu package. For Debian Squeeze I recommend the Ubuntu Lucid package.

Improving performance

For better performance, use this configuration.

 system.swftools.pdf2swf=/usr/bin/pdf2swf -T 9 -f -t -G -s storeallcharacters ${fileIn} -o ${fileOut}

The parameters specifies that:

  • -f : Fonts should be embedded, improves searchability in the document
  • -t : Inserts a stop between each frame, improves stability
  • -G : Makes the document smaller and faster to render
  • -s storeallcharacters : Stores all character information about the texts in the document, improves searchability

OpenKM 5.0.x

Create file pdf2swf_wrapper.sh

#!/bin/bash

/usr/bin/pdf2swf $* -f -t -G -s storeallcharacters

Make it executable:

$ chmod +x pdf2swf_wrapper.sh

And don't forget to change the OpenKM.cfg file:

system.pdf2swf=/path/to/pdf2swf_wrapper.sh

Nota clasica.png Take a look at pdf2swf wiki for complete parameters reference, and remember that JBoss must be restarted after every OpenKM.cfg modification.

Windows

Donwload last swftools http://www.swftools.org/download.html and install it.

Enable in OpenKM.cfg ( put this character to indicate path separator "/" not "\" )

system.pdf2swf=c:/program files/swftools/pdf2swf.exe

Improving performance

For better performance in conversion,

 system.swftools.pdf2swf=c:/path/to/pdf2swf.exe -T 9 -f -t -G -s storeallcharacters ${fileIn} -o ${fileOut}

The parameters specifies that:

  • -f : Fonts should be embedded, improves searchability in the document
  • -t : Inserts a stop between each frame, improves stability
  • -G : Makes the document smaller and faster to render
  • -s storeallcharacters : Stores all character information about the texts in the document, improves searchability

OpenKM 5.0.x

Create file pdf2swf_wrapper.bat

c:\path\to\pdf2swf %1 %2 %3 -f -t -G -s storeallcharacters

And don't forget to change the OpenKM.cfg file:

system.pdf2swf=c:/path/to/pdf2swf_wrapper.bat

Nota clasica.png Take a look at pdf2swf wiki for complete parameters reference, and remember that JBoss must be restarted after every OpenKM.cfg modification.

See also Troubleshooting: Some PDF file not shown in preview.

Conversion problems

Here try to show commons problems with pdf conversion and possible solutions.

Conversion problems with big files

If the document is big (has many pages) or is complex, the conversion may fail with this error:

 ERROR   ID Table overflow
 ERROR   This file is too complex to render- SWF only supports 65536 shapes at once

You can workaround this error adding the -s poly2bitmap parameter which convert graphics to bitmaps:

 system.swftools.pdf2swf=/usr/bin/pdf2swf -T 9 -f -t -G -s poly2bitmap -s storeallcharacters ${fileIn} -o ${fileOut}

See also Troubleshooting: Some PDF file not shown in preview.

Segmentation fault (core dumped)

This is a log of segmentation fault error:

/home/openkm/tomcat-7.0.27/bin/pdf2swf -f -T 9 -t -s bitmap -s storeallcharacters input.pdf -o output.swf
NOTICE  processing PDF page 1 (878x1105:0:0) (move:0:0)
NOTICE  File contains forms
NOTICE  File contains pbm pictures 
NOTICE  File contains soft masks
WARNING multiply blended transparency groups not yet supported!
NOTICE  File contains transparency groups
Segmentation fault (core dumped)

You can try with you can try the -s poly2bitmap or -s bitmap arguments. For our experience seems the bitmap option is more reliable for fixing display issues, but of course you decimate any text, and in some cases increase file size and processing time. You can also add the -s multiply=4 the bitmap argument to get a really crisp bitmap output further increasing size and processing time, but gets you pretty close to the original PDF.