PHP for Word document online browsing function

Source: Internet
Author: User
The first is more traditional, but many predecessors said compatibility is the best, that is, based on the Flash preview scheme, the specific way is to turn word into SWF, and with the help of Flexpaper on the page to achieve a preview. I don't really like this because it doesn't allow the user to manipulate the displayed content, such as copying!
The system using this scheme is currently a bean ding.

The second kind I prefer, that is to turn word into HTML, so you can say goodbye to flash! At present, the practice of Baidu Library is this ~ not only support users directly copy content, but also feel more freedom, but need to develop their own things to achieve more!

Installing OpenOffice
The first step:
Download apache_openoffice_4.1.0_linux_x86_install-rpm_zh-cn.tar.gz

Step Two:
Set up the installation directory, Mkdir/usr/local/openoffice

Step Three:
Put the downloaded file in the directory you built

Fourth Step:
Run command: TAR–ZXVF apache_openoffice_4.1.0_linux_x86_install-rpm_zh-cn.tar.gz

Fifth Step:
After unpacking into the ZH-CN folder, then into the RPMs folder, command RPM–IVH *.rpm

Sixth step:
Go to the Desktop-integration folder under the RPMs folder

Seventh Step:
Command RPM–IVH openoffice.org4.1-redhat-menus-4.1-9764.noarch.rpm

Eighth Step:
Start:/usr/lib/soffice-headless-accept= "SOCKET,HOST=127.0.0.1,PORT=8100;URP;"-nofirststartwizard &

Jodconverter Doc turns into PDF or HTML
Download Address: Http://pan.baidu.com/s/1ntzkuWL
Java-jar/opt/jodconverter-2.2.2/lib/jodconverter-cli-2.2.2.jar/home/php/1.doc/home/php/1.pdf
Because Jodconverter is converted by OpenOffice, it is necessary to install OpenOffice before use, and to start the OpenOffice service before you can use

Install Swftools to convert PDF files to SWF after installation

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

-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: Path to output file

Use Flexpaper to achieve online preview, there is a detailed demo.
To test the document conversion command using PHP:
Document to PDF

$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

$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.
  • Related Article

    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.