Table of Contents
PHP realizes the effect of imitating Baidu Library and Docin online document (word, excel, ppt to flash),
Articles you may be interested in:
Home Backend Development PHP Tutorial PHP realizes the effect of imitating Baidu Wenku and Docin online documents (word, excel, ppt to flash), _PHP tutorial

PHP realizes the effect of imitating Baidu Wenku and Docin online documents (word, excel, ppt to flash), _PHP tutorial

Jul 12, 2016 am 08:57 AM
php Baidu

PHP realizes the effect of imitating Baidu Library and Docin online document (word, excel, ppt to flash),

This article describes the example of PHP realizing imitating Baidu Library and Docin online document Effect. Share it with everyone for your reference, the details are as follows:

Since the project needs to implement functions similar to Baidu Library, and it is a project I am doing alone, I thought of finding a free ready-made one to use. Everything found online is the same. As follows:

Flash Paper supports the direct conversion of Office documents (.doc, .xls, .ppt) to PDF or SWF, which is very fast and has good effect. Unfortunately, Flash Paper has not been updated since V2.2. After installing Flash Paper, you can directly use the command to call FlashPrinter.exe to achieve batch conversion.

For example: C:FlashPaper2.2FlashPrinter.exe C:Flex Technology Introduction.ppt -o C:Flex Technology Introduction.swf

Download FlashPaper. After installation, a virtual printer will appear under the printer in the control panel. This means that the installation is successful. I have tried both 32-bit and 64-bit versions under win7 and cannot install it.

Try the above command on the command line and adjust the path according to yourself. After execution, success means it can be used.

The next step is to use php. PHP uses exec, or system, etc. to execute cmd commands, such as:
Copy code The code is as follows: exec("C:FlashPaper2.2FlashPrinter.exe C:Flex Technology Introduction.ppt -o C:Flex Technology Introduction.swf");

Before executing this, you need to configure the following php.ini. Set the safe mode to off (safe_mode = Off), or leave it on. Set the path that allows exe in safe_mode_exec_dir = and set it to the path of flashpaer.

Test it and it works successfully!

These can all be found on the Internet. Since I am using office 2007, the word suffix .docx failed during the conversion. I can’t find the reason online. Inadvertently, I converted the a The .docx was renamed a.doc and the conversion was successful. I can't figure it out, because it is possible to convert .docx directly under cmd. In the same way, if you want to convert the 2007 ppt or excel, you can convert it by removing the x from the suffix.

Supplement:

Recently, there was a project that required document conversion and reading functions similar to DOCIN, so I started looking for relevant information and finally concluded two solutions. Let’s discuss the respective implementations of the two methods below.

The first method: Convert DOC documents to directly generate SWF through FLASH PAPER. This is very simple. Download a FLASH PAPER and install it to call it. We use CMD to call it in the program. The calling command is: C:Program FilesMacromediaFlashPaper 2FlashPrinter.exe xxx.ppt -o xxx.swf, but after my testing, this thing has a big flaw and cannot be used concurrently, which means that it can only convert one document at the same time. I don’t know if there is any other method. To solve this problem, if you have a solution, please tell me. The conversion principle of FLASH PAPER is as follows: create a virtual printer, open the document, virtually print, obtain the printed content and directly generate SWF, so converting a document requires When a virtual printer is running, a window for printing and opening documents will pop up. This plan does not meet my requirements, so I will pass directly.

The second type: Use the open source software OPENOFFICE to convert the document into PDF, and then use SWFTOOLS to convert the PDF into SWF. There are many things that need to be used. Let’s go through them one by one. This solution can be run under Microsoft system or LINUX. I ran it under CENTOS5.5 character interface. The following is the process:

First install the CENTOS5.5 system. The installation process is no longer tedious. I installed it in the simplest way

After installing the system, download all the required software packages: the software packages we use include

# wget http://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/C DS-CDS_Developer-Site/en_US/-/USD/VerifyItem-Start/ jdk-6u20-linux-i586.bin?BundledLineItemUUID=fdeJ_hC vMVcAAAEpabADyW5K&OrderID=JRuJ_hCvMlQAAAEpWrADyW5K& ProductID=guBIBe.oc_wAAAEnaDJHqPYe&FileName=/jdk-6u 20-linux-i586.bin 
# wget http://download.services.openoffice.org/files/loca lized/zh-cn/3.2.0/OOo_3.2.0_LinuxIntel_install_zh-C N.tar.gz 
# wget http://www.swftools.org/swftools-0.9.1.tar.gz 
wget http://apache.etoak.com/tomcat/tomcat-6/v6.0.26/bi n/apache-tomcat-6.0.26.tar.gz 

Copy after login

There is also an openoffice plug-in, all our applications are based on it: jodconverter

The download address is: http://sourceforge.net/projects/jodconverter/files/

Okay, the software package is ready, let’s start work⌒_⌒

Install JDK & tomcat first, the installation process is not verbose, just google it if you don’t know how to do it

Next, install openoffice,

# tar zxvf OOo_3.2.0_LinuxIntel_install_zh-CN.tar.gz 
#cd OOO320_m12_native_packed-1_zh-CN.9483/RPMS 
#rpm -ivh –force –nodeps *.rpm 

Copy after login

This is how OPENOFFICE is installed. If your system does not have Chinese fonts, install Chinese fonts, otherwise the converted PDF will be garbled

After installing openoffice, then install swftools. The installation of swftools is relatively simple,

# tar zxvf swftools-0.9.1.tar.gz 
#cd swftools-0.9.1 
# ./configure –prefix=/usr/local/swftools/ 
# make && make install 

Copy after login

At this point, all the software that needs to be installed has been installed, since I am now using

Now let’s start all the required services,

First start OPENOFFICE. We start it as a service. The startup command is as follows
Copy code The code is as follows: #/opt/openoffice.org3/program/soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" - nofirststartwizard &

Then start TOMCAT and use jodconverter as a WEB APP conversion service, so first unzip the jodconverter-webapp-2.2.2.zip that was recovered from the disaster, and put jodconverter-webapp-2.2.2.war into the TOMCAT root Directory, after running TOMCAT, the APP folder will be automatically generated. To simplify writing, we rename it to converter. Assume that your server IP is: 192.168.1.123www.linghan56.cn, the TOMCAT port is 8080, and the browser input is: http:/ /192.168.1.123:8080/converter/ and see if the conversion program is running normally. If it starts normally, more than half of our work is completed. The main work has been done, and now the only thing left is how to apply it. I used PHP to call the conversion program, and the user uploaded the file through PHP,

Determine the file type. If it is a JPG, GIF, PNG, PDF, etc. file that can be directly converted using SWFTOOLS, convert it directly. Otherwise, convert the file to PDF through http://192.168.1.123:8080/converter/. Then use SWFTOOLS to convert PDF to SWF. It is worth noting that when converting PDF to SWF, pay attention to converting the version to 9. If you convert to a version below 9, AS3 operation will be very troublesome. The SWFTOOLS conversion command is as follows:
Copy the code The code is as follows: #/usr/local/swftools/bin/pdf2swf -T 9 XXX.pdf XXX.swf

Where -T is the version information, which can be queried through #/usr/local/swftools/bin/pdf2swf -help

Now 3/4 of the whole process is completed. The only thing left is to use AS3 to write something and operate the SWF generated by PDF. The format of the generated SWF file is as follows. Each page of the document will generate a movieclip. Specifically I won’t post the code, I believe this is not difficult.

I originally wanted to put an online DEMO, but the configuration of my VPS is too low, with 512M of memory, and I can’t add swap myself. I ran PHP MYSQL and couldn’t run this. The memory and CPU required for this application are still the same. Quite high.

Comparing the two methods, the first converted thing should be better and support more formats. Theoretically, anything that can be printed can be converted, but it cannot be concurrent, so it is of little significance. If If you can use this principle to write a conversion server yourself to solve concurrency problems, then the first method should be the most suitable.

The second method can only convert formats supported by openoffice, which has very high requirements on the server. I don’t know what the solution is for DOCIN and BAIDU documents

Readers who are interested in more PHP-related content can check out the special topics of this site: "Summary of PHP office document operation skills (including word, excel, access, ppt)", "Summary of PHP date and time usage", "php-oriented "Introduction Tutorial on Object Programming", "Summary of PHP String Usage", "Introduction Tutorial on PHP MySQL Database Operation" and "Summary of Common PHP Database Operation Skills"

I hope this article will be helpful to everyone in PHP programming.

Articles you may be interested in:

  • php check whether the page is included in Baidu
  • php method to get the Baidu snapshot date of the website
  • php get included in Baidu , Baidu hot words and Baidu snapshot method
  • PHP method to calculate the distance between two GPS coordinates on Baidu map
  • php generate Baidu sitemap site map class function instance
  • ThinkPHP Call Baidu translation class to achieve online translation
  • php code example using Baidu ping service
  • How to create PowerPoint2007 document using PHP
  • Principles and examples of using PHP to export Word documents
  • Customized php class (search/modify) xml document
  • PHP generated Flash animation implementation code
  • flash php mysql to create a simple message book tutorial
  • Use PHP dynamic Create Flash animation

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1108614.htmlTechArticlePHP realizes the effect of imitating Baidu Library and Docin online documents (word, excel, ppt to flash), this article describes the examples Use PHP to achieve the effect of imitating Baidu Library and Docin online documents. Sharing it with everyone for your reference,...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1268
29
C# Tutorial
1242
24
PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP in Action: Real-World Examples and Applications PHP in Action: Real-World Examples and Applications Apr 14, 2025 am 12:19 AM

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

The Enduring Relevance of PHP: Is It Still Alive? The Enduring Relevance of PHP: Is It Still Alive? Apr 14, 2025 am 12:12 AM

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP vs. Python: Understanding the Differences PHP vs. Python: Understanding the Differences Apr 11, 2025 am 12:15 AM

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP vs. Other Languages: A Comparison PHP vs. Other Languages: A Comparison Apr 13, 2025 am 12:19 AM

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP and Python: Code Examples and Comparison PHP and Python: Code Examples and Comparison Apr 15, 2025 am 12:07 AM

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP and Python: Different Paradigms Explained PHP and Python: Different Paradigms Explained Apr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

See all articles