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

From OpenKM Documentation
Jump to: navigation, search
(Segmentation fault (core dumped))
 
(41 intermediate revisions by 2 users not shown)
Line 1: Line 1:
To enable preview UI tab, OpenKM need to convert pdf files to swf.  
+
{{TOCright}} __TOC__
 +
 
 +
To enable preview UI tab, OpenKM need to convert pdf files to swf.
 +
 
 +
{{Warning|Starting from OpenKM 5.1 this configuration property has changed to '''system.swftools.pdf2swf'''.}}
 +
 
 +
{{Note|Since OpenKM 5.1.9 the pdf2swf command line parameters should be added in the configuration property, for example:
 +
  <nowiki>system.swftools.pdf2swf=/usr/bin/pdf2swf -T 9 -f ${fileIn} -o ${fileOut}</nowiki>
 +
}}
 +
 
 +
See [http://flexpaper.devaldi.com/docs_converting.jsp FlexPaper: Converting Documents] for more info.
  
 
== Linux ==
 
== Linux ==
 +
=== Ubuntu===
 
Swftools can be installed running in terminal:
 
Swftools can be installed running in terminal:
  
 
  $ sudo aptitude install swftools
 
  $ sudo aptitude install swftools
  
Enable in OpenKM.cfg  
+
Enable in [[OpenKM.cfg]] or Administration > Configuration depending on your OpenKM version:
  
  system.pdf2swf=/usr/bin/pdf2swf
+
  system.swftools.pdf2swf=/usr/bin/pdf2swf
  
 
{{Note|In Ubuntu 10.04 is possible you need to add this line to '''/etc/apt/sources.list'''
 
{{Note|In Ubuntu 10.04 is possible you need to add this line to '''/etc/apt/sources.list'''
Line 14: Line 25:
 
}}
 
}}
  
{{Note|In Ubuntu 10.10 this package is not included, so you need to compile it or grab from https://launchpad.net/~tldm217/+archive/coba.}}
+
{{Note|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 ===
 
=== Red hat ===
 
Better if you compile version 0.9.x
 
Better if you compile version 0.9.x
  
  yum install zlib-devel libjpeg-devel giflib-devel freetype-devel gcc gcc-c++
+
  $ yum install zlib-devel libjpeg-devel giflib-devel freetype-devel gcc gcc-c++
  wget http://www.swftools.org/swftools-0.9.1.tar.gz
+
  $ wget http://www.swftools.org/swftools-0.9.1.tar.gz
  tar xzf swftools-0.9.1.tar.gz
+
  $ tar xzf swftools-0.9.1.tar.gz
  cd swftools-0.9.1
+
  $ cd swftools-0.9.1
  ./configure
+
  $ ./configure --prefix=/usr/local
  make
+
  $ make
  make install  
+
  $ make install  
  
=== Up to version 4.1 and earlier ===
+
=== Debian ===
 +
This package is not include in the Debian repositories, so you need to compile from source:
  
{{Note|In version 5.x and upper params are passed dicrectly by OpenKM.}}
+
$ 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
  
'''For better performance, use this configuration:'''
+
Or you can try to install the Ubuntu package. For Debian Squeeze I recommend the Ubuntu Lucid package.
  
Create file pdf2swf_wrapper.sh
+
=== Improving performance ===
 +
For better performance, use this configuration.
  
<source lang="bash">
+
  system.swftools.pdf2swf=/usr/bin/pdf2swf -T 9 -f -t -G -s storeallcharacters ${fileIn} -o ${fileOut}
#!/bin/bash
 
  
/usr/bin/pdf2swf $* -f -T 9 -t -G -s storeallcharacters
+
The parameters specifies that:
</source>
 
 
 
The last 5 parameters specifies that:
 
  
 
* -f : Fonts should be embedded, improves searchability in the document
 
* -f : Fonts should be embedded, improves searchability in the document
* -T 9 : Sets the target flash version to 9, improves stability
 
 
* -t : Inserts a stop between each frame, improves stability
 
* -t : Inserts a stop between each frame, improves stability
 
* -G : Makes the document smaller and faster to render
 
* -G : Makes the document smaller and faster to render
 
* -s storeallcharacters : Stores all character information about the texts in the document, improves searchability  
 
* -s storeallcharacters : Stores all character information about the texts in the document, improves searchability  
 +
 +
==== OpenKM 5.0.x ====
 +
Create file pdf2swf_wrapper.sh
 +
 +
<source lang="bash">
 +
#!/bin/bash
 +
 +
/usr/bin/pdf2swf $* -f -t -G -s storeallcharacters
 +
</source>
  
 
Make it executable:
 
Make it executable:
Line 53: Line 80:
 
  $ chmod +x pdf2swf_wrapper.sh
 
  $ chmod +x pdf2swf_wrapper.sh
  
And don't forget to change the OpenKM.cfg file:
+
And don't forget to change the [[OpenKM.cfg]] file:
  
 
<source lang="java">
 
<source lang="java">
Line 59: Line 86:
 
</source>
 
</source>
  
{{Note| If you've configured flexpaper viewer in OpenKM.cfg, these parameters are not needed because we call pdf2swf with it by default.}}
+
{{Note|Take a look at [http://wiki.swftools.org/index.php/Pdf2swf pdf2swf wiki] for complete parameters reference, and remember that JBoss must be restarted after every [[OpenKM.cfg]] modification.}}
  
 
== Windows ==
 
== Windows ==
 
Donwload last swftools http://www.swftools.org/download.html and install it.
 
Donwload last swftools http://www.swftools.org/download.html and install it.
  
Enable in OpenKM.cfg ( put this character to indicate path separator "/" not "\" )
+
Enable in [[OpenKM.cfg]] ( put this character to indicate path separator "/" not "\" )
  
 
  system.pdf2swf=c:/program files/swftools/pdf2swf.exe
 
  system.pdf2swf=c:/program files/swftools/pdf2swf.exe
  
=== Up to version 4.1 and earlier ===
+
=== Improving performance ===
 +
For better performance in conversion,
  
{{Note|In version 5.x and upper params are passed dicrectly by OpenKM.}}
+
  system.swftools.pdf2swf=c:/path/to/pdf2swf.exe -T 9 -f -t -G -s storeallcharacters ${fileIn} -o ${fileOut}
  
'''For better performance configuration you can doing:'''
+
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
 
Create file pdf2swf_wrapper.bat
  
 
<source lang="bash">
 
<source lang="bash">
c:\path\to\pdf2swf %1 %2 %3 -f -T 9 -t -G -s storeallcharacters
+
c:\path\to\pdf2swf %1 %2 %3 -f -t -G -s storeallcharacters
 
</source>
 
</source>
  
The last 5 parameters specifies that:
+
And don't forget to change the [[OpenKM.cfg]] file:
 
 
* -f : Fonts should be embedded, improves searchability in the document
 
* -T 9 : Sets the target flash version to 9, improves stability
 
* -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
 
 
 
And don't forget to change the OpenKM.cfg file:
 
  
 
<source lang="java">
 
<source lang="java">
Line 94: Line 120:
 
</source>
 
</source>
  
{{Note| If you've configured flexpaper viewer in OpenKM.cfg, these parameters are not needed because we call pdf2swf with it by default.}}
+
{{Note|Take a look at [http://wiki.swftools.org/index.php/Pdf2swf 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|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|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 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)
  
{{Note| Take a look at pdf2swf wiki[http://wiki.swftools.org/index.php/Pdf2swf] for complete parameters reference}}
+
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.
  
{{Note| Remember that JBoss must be restarted after any OpenKM.cfg modification.}}
+
/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  Writing SWF file output.swf
  
 
[[Category: Installation Guide]]
 
[[Category: Installation Guide]]
[[Category:OKM Network]]
 

Latest revision as of 11:34, 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 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.

/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  Writing SWF file output.swf