Home php教程 php手册 将word转化为swf 如同百度文库般阅读实现思路及代码

将word转化为swf 如同百度文库般阅读实现思路及代码

Jun 13, 2016 am 11:42 AM
span style swf word code copy accomplish Will Ideas Baidu change read

复制代码 代码如下:


实现如同百度文库那样类似功能需要进行一系列转化,一般流程想将word转化为pdf格式,再将pdf格式转化为swf格式。在网页上显示其实都是swf格式内容。


首先将word转化为swf,需要调用com组件,可以通过office 或者wps进行转化,但我尝试都没有成功,最后通过OpenOffice 4.0.0 进行转化才成功,OpenOffice 4.0.0支持windows 和linux操作系统,故需要先下载openOffice,官网上应该有。将word转化为pdf,好像只是支持英文的标题的文档,不支持汉文名字文档,可以先将文件重新命名为英文,转化之后再将文件变为汉文即可,可能还需要开始openoffice 服务,上图
 
验证服务是否开启,上图
 
代码如下:

复制代码 代码如下:


<?php <BR>class RunTime//页面执行时间类 <BR>{ <BR>private $starttime;//页面开始执行时间 <BR>private $stoptime;//页面结束执行时间 <BR>private $spendtime;//页面执行花费时间 <BR>function getmicrotime()//获取返回当前微秒数的浮点数 <BR>{ <BR>list($usec,$sec)=explode(" ",microtime()); <BR>return ((float)$usec + (float)$sec); <BR>} <BR>function start()//页面开始执行函数,返回开始页面执行的时间 <BR>{ <BR>$this->starttime=$this->getmicrotime(); <BR>} <BR>function end()//显示页面执行的时间 <BR>{ <BR>$this->stoptime=$this->getmicrotime(); <BR>$this->spendtime=$this->stoptime-$this->starttime; <BR>//return round($this->spendtime,10); <BR>} <BR>function display() <BR>{ <BR>//$this->end(); <BR>echo "<p>运行时间:".round($this->spendtime,10)."秒</p>"; <BR>} <BR>} <BR>/*调用方法 */ <BR>$timer=new Runtime(); <BR>$timer->start(); <br><br><BR>function MakePropertyValue($name,$value,$osm){ <BR>$oStruct = $osm->Bridge_GetStruct <BR>("com.sun.star.beans.PropertyValue"); <BR>$oStruct->Name = $name; <BR>$oStruct->Value = $value; <BR>return $oStruct; <BR>} <BR>function word2pdf($doc_url, $output_url){ <BR>$osm = new COM("com.sun.star.ServiceManager") or die ("Please be sure that OpenOffice.org is installed.\n"); <BR>$args = array(MakePropertyValue("Hidden",true,$osm)); <BR>$oDesktop = $osm->createInstance("com.sun.star.frame.Desktop"); <BR>$oWriterDoc = $oDesktop->loadComponentFromURL <BR>($doc_url,"_blank", 0, $args); <BR>$export_args = array(MakePropertyValue <BR>("FilterName","writer_pdf_Export",$osm)); <BR>$oWriterDoc->storeToURL($output_url,$export_args); <BR>$oWriterDoc->close(true); <BR>} <BR>$output_dir = "C:/"; <BR>$doc_file = "C:/t.doc"; <BR>$pdf_file = "9.pdf"; <BR>$output_file = $output_dir . $pdf_file; <BR>$doc_file = "file:///" . $doc_file; <BR>$output_file = "file:///" . $output_file; <BR>word2pdf($doc_file,$output_file); <br><br><BR>$timer->end(); <BR>$timer->display(); <br><br>?>
Copy after login



Copy after login





花费时间进行分析:

将一个大小为1.48M的word文档转化为pdf需要运行时间:1.3652579784秒 自己电脑是这个时间,自己测试





其次将pdf转化为swf,需要运用另外一个软件,swftools 通过代码调用cmd命令,直接上代码


<?php <BR>class RunTime//页面执行时间类 <BR>{ <BR>private $starttime;//页面开始执行时间 <BR>private $stoptime;//页面结束执行时间 <BR>private $spendtime;//页面执行花费时间 <BR>function getmicrotime()//获取返回当前微秒数的浮点数 <BR>{ <BR>list($usec,$sec)=explode(" ",microtime()); <BR>return ((float)$usec + (float)$sec); <BR>} <BR>function start()//页面开始执行函数,返回开始页面执行的时间 <BR>{ <BR>$this->starttime=$this->getmicrotime(); <BR>} <BR>function end()//显示页面执行的时间 <BR>{ <BR>$this->stoptime=$this->getmicrotime(); <BR>$this->spendtime=$this->stoptime-$this->starttime; <BR>//return round($this->spendtime,10); <BR>} <BR>function display() <BR>{ <BR>//$this->end(); <BR>echo "<p>运行时间:".round($this->spendtime,10)."秒</p>"; <BR>} <BR>} <BR>/*调用方法 */ <BR>$timer=new Runtime(); <BR>$timer->start(); <br><br><BR>//调用系统软件 <BR>$command = "\"C:\Program Files\SWFTools\pdf2swf.exe\" -t C:\8.pdf -s flashversion=9 -o C:\m.swf"; <BR>echo $command; <BR>exec($command); <BR>echo 'ok'; <br><br><BR>$timer->end(); <BR>$timer->display(); <br><br>?>
Copy after login


将刚才转化而来的pdf转化为swf文件需要用运行时间:1.3119211197秒时间


最后则是将swf文件显示在网页中,这一步需要引入多个js文件和其他文件,代码就不写了,直接下载,在我的上传资料中













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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

deepseek web version entrance deepseek official website entrance deepseek web version entrance deepseek official website entrance Feb 19, 2025 pm 04:54 PM

DeepSeek is a powerful intelligent search and analysis tool that provides two access methods: web version and official website. The web version is convenient and efficient, and can be used without installation; the official website provides comprehensive product information, download resources and support services. Whether individuals or corporate users, they can easily obtain and analyze massive data through DeepSeek to improve work efficiency, assist decision-making and promote innovation.

After 2 months, the humanoid robot Walker S can fold clothes After 2 months, the humanoid robot Walker S can fold clothes Apr 03, 2024 am 08:01 AM

Editor of Machine Power Report: Wu Xin The domestic version of the humanoid robot + large model team completed the operation task of complex flexible materials such as folding clothes for the first time. With the unveiling of Figure01, which integrates OpenAI's multi-modal large model, the related progress of domestic peers has been attracting attention. Just yesterday, UBTECH, China's "number one humanoid robot stock", released the first demo of the humanoid robot WalkerS that is deeply integrated with Baidu Wenxin's large model, showing some interesting new features. Now, WalkerS, blessed by Baidu Wenxin’s large model capabilities, looks like this. Like Figure01, WalkerS does not move around, but stands behind a desk to complete a series of tasks. It can follow human commands and fold clothes

How to implement the WeChat clone function on Huawei mobile phones How to implement the WeChat clone function on Huawei mobile phones Mar 24, 2024 pm 06:03 PM

How to implement the WeChat clone function on Huawei mobile phones With the popularity of social software and people's increasing emphasis on privacy and security, the WeChat clone function has gradually become the focus of people's attention. The WeChat clone function can help users log in to multiple WeChat accounts on the same mobile phone at the same time, making it easier to manage and use. It is not difficult to implement the WeChat clone function on Huawei mobile phones. You only need to follow the following steps. Step 1: Make sure that the mobile phone system version and WeChat version meet the requirements. First, make sure that your Huawei mobile phone system version has been updated to the latest version, as well as the WeChat App.

Introduction to how to obtain Baidu Xiyang Shells Introduction to how to obtain Baidu Xiyang Shells Mar 28, 2024 am 09:11 AM

There are many users in Xirang who don’t know where the shells are and how to get them. Some players have been searching for several hours but still can’t find them. Below, the editor will introduce how to obtain Baidu Xirang shells. Come and take a look. . How to get Baidu Xirang Shell 1. First we need to come to the community, and then come to the location in the picture below. 2. Select the destination here and choose to enter the 188th floor. 3. After entering the 188th floor, you will see this prompt when walking around. Just click I Got It. 4. The location of the shell may be a little difficult to find. Just behind the 188 elevator, there is a small glowing dot that is the shell. 5. You need to use a VR controller to pick up shells. Just click on the shell. Redemption method 1. First click the "Settings" icon in the upper right corner of the page and select "

Baidu Apollo releases Apollo ADFM, the world's first large model that supports L4 autonomous driving Baidu Apollo releases Apollo ADFM, the world's first large model that supports L4 autonomous driving Jun 04, 2024 pm 08:01 PM

On May 15, Baidu Apollo held Apollo Day 2024 in Wuhan Baidu Luobo Automobile Robot Zhixing Valley, comprehensively demonstrating Baidu's major progress in autonomous driving over the past ten years, bringing technological leaps based on large models and a new definition of passenger safety. With the world's largest autonomous vehicle operation network, Baidu has made autonomous driving safer than human driving. Thanks to this, safer, more comfortable, green and low-carbon travel methods are turning from ideal to reality. Wang Yunpeng, vice president of Baidu Group and president of the Intelligent Driving Business Group, said on the spot: "Our original intention to build autonomous vehicles is to satisfy people's growing yearning for better travel. People's satisfaction is our driving force. Because safety, So beautiful, we are happy to see

Tsinghua University and Zhipu AI open source GLM-4: launching a new revolution in natural language processing Tsinghua University and Zhipu AI open source GLM-4: launching a new revolution in natural language processing Jun 12, 2024 pm 08:38 PM

Since the launch of ChatGLM-6B on March 14, 2023, the GLM series models have received widespread attention and recognition. Especially after ChatGLM3-6B was open sourced, developers are full of expectations for the fourth-generation model launched by Zhipu AI. This expectation has finally been fully satisfied with the release of GLM-4-9B. The birth of GLM-4-9B In order to give small models (10B and below) more powerful capabilities, the GLM technical team launched this new fourth-generation GLM series open source model: GLM-4-9B after nearly half a year of exploration. This model greatly compresses the model size while ensuring accuracy, and has faster inference speed and higher efficiency. The GLM technical team’s exploration has not

Practical methods to solve the problem of cross-page display of Word tables Practical methods to solve the problem of cross-page display of Word tables Mar 25, 2024 pm 07:27 PM

In daily work and study, we often use Word to write documents and create tables. However, when dealing with long tables, it is very common to encounter the situation where the table content is displayed across pages. At this time, some practical methods need to be adopted to solve this problem. The first method is to adjust the row height and column width. In Word, you can try to make the table content display completely on one page by adjusting the row height and column width. First, select the row or column that needs to be adjusted, then right-click and select &quot;Row Height&quot; or &quot;Column Width&quot; to adjust it to the appropriate size. if

Put a √ symbol in the word box Put a √ symbol in the word box May 07, 2024 pm 01:06 PM

1. Open the Word document and move the cursor to the position in the box where the √ symbol needs to be inserted. 2. Select the [Insert] option on the menu bar. In the [Insert] option, find the [Symbol] group and click the [Symbol] button. 3. In the pop-up symbol dialog box, select the [Common Mathematical Symbols] category and find the [√] symbol among the common mathematical symbols. 4. Click the √ symbol and click the [Insert] button to insert the √ symbol in the box.

See all articles