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)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

What is Cross-Site Request Forgery (CSRF) and how do you implement CSRF protection in PHP? What is Cross-Site Request Forgery (CSRF) and how do you implement CSRF protection in PHP? Apr 07, 2025 am 12:02 AM

In PHP, you can effectively prevent CSRF attacks by using unpredictable tokens. Specific methods include: 1. Generate and embed CSRF tokens in the form; 2. Verify the validity of the token when processing the request.

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.

Explain the match expression (PHP 8 ) and how it differs from switch. Explain the match expression (PHP 8 ) and how it differs from switch. Apr 06, 2025 am 12:03 AM

In PHP8, match expressions are a new control structure that returns different results based on the value of the expression. 1) It is similar to a switch statement, but returns a value instead of an execution statement block. 2) The match expression is strictly compared (===), which improves security. 3) It avoids possible break omissions in switch statements and enhances the simplicity and readability of the code.

The Future of PHP: Adaptations and Innovations The Future of PHP: Adaptations and Innovations Apr 11, 2025 am 12:01 AM

The future of PHP will be achieved by adapting to new technology trends and introducing innovative features: 1) Adapting to cloud computing, containerization and microservice architectures, supporting Docker and Kubernetes; 2) introducing JIT compilers and enumeration types to improve performance and data processing efficiency; 3) Continuously optimize performance and promote best practices.

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

See all articles