PHP to achieve Word document online Browsing function, configuration installation Notes

Source: Internet
Author: User
Tags php script

Welcome to join the PHP architect Group: 410028331 (Recruit wise-Master) communication of technical convenience

Generally similar to OA or CRM and other management systems may encounter the need to view the Word document, similar to the function of Baidu Library.

Remember last year, a member of the team in charge of the project needs this function, said later is the implementation of more difficult, will be in the CHM format instead. Today, I saw online article "Linux php file Conversion", how to use OpenOffice 3 under Linux, pdf2swf tool, Jodconverter, flexpaper, to achieve the online document view.

Try installing them again under Ubuntu, as follows:

Because the Ubuntu version is 10.0.4,openoffice already installed by default. If you do not install OpenOffice, Google installation.
First step: Install Jodconverter, after installation can implement DOC document into PDF.

File Download Address is Http://www.artofsolving.com/opensource/jodconverter
After downloading the direct decompression, decompression 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-cli-2.2.2.jar/home/php/1.doc/home/php/1.pdf

This prompts for a missing Java package and prompts several installation packages. Choose me to install openjdk-6-jre-headless, the command is as follows:

sudo apt_get openjdk-6-jre-headless

After installation, run the name of the doc-turn PDF above, prompting the OpenOffice process to not start.

Because the jodconverter is converted through OpenOffice, it is necessary to install OpenOffice before use, and to start the OpenOffice service before use. Start command

/usr/lib/soffice-headless-accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard &

The command to run the doc to PDF above is already successful.

Step Two: Install Swftools, after installation can realize PDF file into 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-t-z-t-f/home/php/1.pdf-s flashversion=9

Step three: Use Flexpaper to realize online preview, which has detailed demo.

Step Fourth: Use PHP to test document conversion commands:
Document Transfer 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 Transfer 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 there may be a problem with permissions that cannot be performed
Which I tested using the PHP script called pdf2swf to make the transform file, can not be generated. This allows you to configure only Apache user rights to ensure that the configured user has permission to run the pdf2swf command
The default installed PHP environment Ubuntu under the configuration 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 used under Windows to manually transfer the PDF file to the SWF for online viewing.

The steps are organized as follows:

1. After installing PDF2SWF tool, make a PDF transfer 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: The source file path, which is the PDF file path to be converted.
-S: Set parameters, here we set to flashversion=9, that is, can be converted to version 9.
-O: Path to output file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.