将word转化为swf 如同百度文库般阅读实现思路及代码
复制代码 代码如下:
实现如同百度文库那样类似功能需要进行一系列转化,一般流程想将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>?>
花费时间进行分析:
将一个大小为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>?>
将刚才转化而来的pdf转化为swf文件需要用运行时间:1.3119211197秒时间
最后则是将swf文件显示在网页中,这一步需要引入多个js文件和其他文件,代码就不写了,直接下载,在我的上传资料中

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

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.

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 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.

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 "

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

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

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 "Row Height" or "Column Width" to adjust it to the appropriate size. if

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.
