First step: Install the Jodconverter, after the installation can implement the doc document into PDF.
File is Http://www.artofsolving.com/opensource/jodconverter
After downloading the direct decompression, extracted to the/OPT directory/opt/jodconverter-2.2.2/, the use of the file is installed in the package Lib/jodconverter-cli-2.2.2.jar.
Test whether you can use
- java -jar / opt/jodconverter-2.2 2/lib/jodconverter< Span class= "pun" >-cli-2.2. 2.jar /home/php/1.doc /home /php/1.pdf
The Java package is missing and prompts several installation packages. Select I install openjdk-6-jre-headless, the command is as follows:
- sudo apt_get openjdk-6-JRE-headless
After installation, the name of the above doc to PDF will be run, prompting the OpenOffice process not to start,
Because the Jodconverter is converted by OpenOffice, it is necessary to install the OpenOffice before use, and to start the OpenOffice service before it can be used. Start command
sudo/usr/bin/soffice-headless-accept= "Socket,host=127.0.0.1,port=8100;urp" –nofirststartwizard
The command to run the above doc to PDF has been successful.
If the system does not follow OpenOffice or has been installed Liboffice
Refer to the steps below
If the system has LibreOffice installed
Refer to the steps below
If LibreOffice is installed, execute sudo apt-get purge libreoffice*
One, download the "OpenOffice.org" of the Deb installation package
Download the Deb installer package on the Chinese official website: Http://download.openoffice.org/other.html#en-US, now (June 1, 2011) The latest version is 3.3.0, the file I downloaded is "ooo_3.3.0_ Linux_x86_install-deb_zh-cn.tar.gz ". and copy the downloaded file to the home directory (that is, the current logged in user's home directory, so that the folder name without the Chinese characters, can prevent accidents).
Second, uninstall "LibreOffice"
Uninstall "LibreOffice" with "New Get" or "Software Center". With the new Rieter Uninstall, in the new state search "LibreOffice", the results of "LibreOffice" installed files are uninstalled.
Third, install "OpenOffice.org":
1. Unzip the file
Open terminal, enter command:
sudo tar-zxvf ooo_3.3.0_linux_x86_install-deb_zh-cn.tar.gz, get the folder "ooo330_m20_native_packed-1_zh-cn.9567".
2. Enter the "Debs" folder in the extracted folder
Command: CD./ooo330_m20_native_packed-1_zh-cn.9567/debs.
3. Install the main file
Command: sudo dpkg-i *.deb installs all the ". Deb" Files in the "Debs" package. After all the files in this package have been installed, you cannot find the "OpenOffice.org" shortcut under the "Office" menu of the system menu and continue with the installation.
4. Go to "desktop-integration" folder in "Debs" package
Command: CD desktop-integration.
5. Install "OpenOffice.org" shortcut
To install the ". Deb" file in the "desktop-integration" folder, command:
sudo dpkg-i *.deb, after this command finishes, if there are no error prompts, OK. You can then find the "OpenOffice.org" shortcut in the "Office" menu in the System menu.
Second step: Install Swftools, after installation can realize PDF file to SwF
- 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
- Make
- Make install
Test whether you can use
pdf2swf -o /home/php/1.swf -z -t -F / Home/php/1.pdf -s flashversion=9
The third step: using Flexpaper to achieve online preview, there is a detailed demo.
Fourth step: Use the PHP test document Conversion command:
Document to PDF
- <? PHP
- $doc = './docs/test.txt ';
- $formatName = './pdf/test.pdf ';
- $command = ' Java-jar/opt/jodconverter-2.2.2/lib/jodconverter-cli-2.2.2.jar '. $doc.' '. $formatName;
- EXEC($command);
- echo ' OK ';
PDF to SWF
- <? PHP
- $pdf = './pdf/test.pdf ';
- $swf = './swf/test.swf ';
- $command = '/usr/local/wenku/swftools-0.9.1/src/pdf2swf-o '. $swf.'-t-z-t-f '. $pdf.'-S flashversion=9 ';
- EXEC($command);
- echo ' OK ';
PHP script to run the above command may have permissions problem cannot be executed
One of the PHP scripts I used to test called pdf2swf to convert the file, not generated. This allows you to configure Apache user rights to ensure that the configured user has permission to run the pdf2swf command
The default installation of the PHP environment under Ubuntu Config file is/etc/apache2/apache2.conf modify these two lines,
User ${apache_run_user}
Group ${apache_run_user}
After the configuration is complete, restart Apache.
/etc/init.d/apache2 restart
The installation configuration under this Linux is over.
Window under test
Download the pdf2swf tool and Flexpaper, which are used under window, and manually turn the PDF file into SWF for online viewing.
The steps are organized as follows:
1. After installing the PDF2SWF tool, proceed to convert the PDF to SWF. CMD command line:
Pdf2swf.exe-t D:\wamp5.3\www\test\pdf\c.pdf-s Flashversion=9-o D:\wamp5.3\www\test\swf\c.swf
-T: Source file path, which is the path of the PDF file to be converted.
-S: Set the parameters, here we set to flashversion=9, that can be converted to 9 version.
-O: The path to the output file, where I output to D: Disk
Results of the operation:
2. Use the Flexpaper plugin to display the browse SWF file. The version used here is 1.5.8 Flash version (Release Notes). In the package there is already an HTML version of the demo, slightly change the next sentence can be achieved.
The code is as follows:
- <script src= "js/flexpaper_flash.js" type= "text/javascript" ></SCRIPT>
- <a id="Viewerplaceholder" style="width:680px; Height:480px; Display:block;" /></a>
- <script Type="Text/javascript">
- var fp = new flexpaperviewer(
- ' Flexpaperviewer ',
- ' Viewerplaceholder ', { config : {
- swffile : escape(' c.swf '),
- scale : 0.1,
- zoomtransition : ' EaseOut ',
- zoomtime : 0.5,
- zoominterval : 0.2,
- fitpageonload : true,
- fitwidthonload : false,
- Fullscreenasmaxwindow : false,
- progressiveloading : false,
- minzoomsize : 0.2,
- maxzoomsize : 5,
- searchmatchall : false,
- initviewmode : ' Portrait ',
- printpaperasbitmap : false,
- viewmodetoolsvisible : true,
- zoomtoolsvisible : true,
- navtoolsvisible : true,
- cursortoolsvisible : true,
- searchtoolsvisible : true,
- Localechain: ' en_US '
- }})
- </script>
This is the end, to see the effect achieved: