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

Video Face Swap

Video Face Swap

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

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
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)

Hot Topics

Java Tutorial
1670
14
PHP Tutorial
1276
29
C# Tutorial
1256
24
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

Baidu Robin Li led a team to visit PetroChina to discuss the intelligence of the oil and gas industry Baidu Robin Li led a team to visit PetroChina to discuss the intelligence of the oil and gas industry May 07, 2024 pm 06:13 PM

According to news from this site on May 7, on May 6, Robin Li, founder, chairman and CEO of Baidu, led a team to visit China National Petroleum Corporation (hereinafter referred to as "PetroChina") in Beijing and met with directors of China National Petroleum Corporation Chairman and Party Secretary Dai Houliang held talks. The two parties had in-depth exchanges on strengthening cooperation and promoting the deep integration of the energy industry with digital intelligence. PetroChina will accelerate the construction of a digital China Petroleum Corporation, strengthen cooperation with Baidu Group, promote the in-depth integration of the energy industry with digital intelligence, and make greater contributions to ensuring national energy security. Robin Li said that the "intelligent emergence" and core capabilities of understanding, generation, logic, and memory displayed by large models have opened up a broader space for imagination for the combination of cutting-edge technology and oil and gas business. Always

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

How to convert pdf to word How to convert pdf to word Apr 30, 2024 pm 05:58 PM

1. Use online conversion tools such as Smallpdf, Adobe Acrobat or Zamzar. 2. These tools usually provide an easy-to-use interface, allowing users to upload PDF files and optionally convert them to Word format. 3. After the conversion is completed, users can download the Word document and perform further editing. 4. Use professional PDF conversion software, such as Adobe Acrobat Pro or Wondershare PDFelement.

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.

It is reported that the Chinese version of Samsung Galaxy S24 series mobile phone 'Search in Circle” will support Google search It is reported that the Chinese version of Samsung Galaxy S24 series mobile phone 'Search in Circle” will support Google search Jun 01, 2024 am 09:54 AM

According to news on May 31, blogger @ibinguniverse broke the news today that the Chinese version of Samsung Galaxy S24 series mobile phones will support Google search. The blogger did not disclose the specific launch time. According to Samsung’s previous introduction, the Samsung Galaxy S24 series has been equipped with many high-level AI capabilities, AI-based practical functions such as input, translation, recorder, notes, and cameras, to provide users with a more convenient and efficient comprehensive experience. Different from the overseas version, most of the AI ​​functions of the Samsung Galaxy S24 series are provided by domestic manufacturers, such as Baidu. Previously reported, Galaxy AI deeply integrates multiple capabilities of Baidu Wenxin large model, which can provide end-side enabled call and translation functions, as well as intelligent summary brought by generative AI.

The Mistral open source code model takes the throne! Codestral is crazy about training in over 80 languages, and domestic Tongyi developers are asking to participate! The Mistral open source code model takes the throne! Codestral is crazy about training in over 80 languages, and domestic Tongyi developers are asking to participate! Jun 08, 2024 pm 09:55 PM

Produced by 51CTO technology stack (WeChat ID: blog51cto) Mistral released its first code model Codestral-22B! What’s crazy about this model is not only that it’s trained on over 80 programming languages, including Swift, etc. that many code models ignore. Their speeds are not exactly the same. It is required to write a "publish/subscribe" system using Go language. The GPT-4o here is being output, and Codestral is handing in the paper so fast that it’s hard to see! Since the model has just been launched, it has not yet been publicly tested. But according to the person in charge of Mistral, Codestral is currently the best-performing open source code model. Friends who are interested in the picture can move to: - Hug the face: https

Create Agent in one sentence! Robin Li: The era is coming when everyone is a developer Create Agent in one sentence! Robin Li: The era is coming when everyone is a developer Apr 17, 2024 pm 02:28 PM

The big model subverts everything, and finally got to the head of this editor. It is also an Agent that was created in just one sentence. Like this, give him an article, and in less than 1 second, fresh title suggestions will come out. Compared to me, this efficiency can only be said to be as fast as lightning and as slow as a sloth... What's even more incredible is that creating this Agent really only takes a few minutes. Prompt belongs to Aunt Jiang: And if you also want to experience this subversive feeling, now, based on the new Wenxin intelligent agent platform launched by Baidu, everyone can create their own intelligent assistant for free. You can use search engines, smart hardware platforms, speech recognition, maps, cars and other Baidu mobile ecological channels to let more people use your creativity! Robin Li himself

See all articles