乔山办公网我们一直在努力
您的位置:乔山办公网 > office365 > 如何使用php获取word文档的页数-PHP获取office文件页数,设置文档页数

如何使用php获取word文档的页数-PHP获取office文件页数,设置文档页数

作者:乔山办公网日期:

返回目录:office365


<?php
/*
* 必须将 php.ini 中的 com.allow_dcom 设为 TRUE
*/

function php_Word($wordname,$htmlname,$content)
{
//获取链接地址
$url = $_SERVER['HTTP_HOST'];
$url = ";
$url = $url.$_SERVER['PHP_SELF'];
$url = dirname($url)."/";
//建立一个指向新COM组件的索引
$word = new COM("word.application") or die("Unable to instanciate Word");

//显示目前正在使用的Word的版本号
echo "Loading Word, v. {$word->Version}";

//把它的可见性设置为0(假),如果要使它在最前端打开,使用1(真)
$word->Visible = 1;
//---------------------------------读取Word内容操作 START-----------------------------------------
//打开一个word文档
$word->Documents->Open($url.$wordname);

//将filename.doc转换为html格式,并保存为html文件
$word->Documents[1]->SaveAs(dirname(__FILE__)."/".$htmlname,8);

//获取htm文件内容并输出到页面 (文本的样式不会丢失)
$content = file_get_contents($url.$htmlname);
echo $content;

//获取word文档内容并输出到页面(文本的原样式已丢失)
$content= $word->ActiveDocument->content->Text;
echo $content;

//关闭与COM组件之间的连接
$word->Documents->close(true);
$word->Quit();
$word = null;
unset($word);
//---------------------------------新建立Word文档操e68a84e79fa5e98193337作 START--------------------------------------
//建立一个空的word文档
$word->Documents->Add();

//写入内容到新建word
$word->Selection->TypeText("$content");

//保存新建的word文档
$word->Documents[1]->SaveAs(dirname(__FILE__)."/".$wordname);

//关闭与COM组件之间的连接
$word->Quit();
}
php_Word("tesw.doc","filename.html","写入word的内容");
?>

string dir = basename(fullPath);
if(!_fileUtils->isDirectoryExist(dir)) {
if(!_fileUtils->createDirectory(dir)) {
// Failed to create directory
CCLOG("AssetsManagerEx : can not create directory %s\n", fullPath.c_str());
unzClose(zipfile);
return false;
}
  • “文档首页的页码设置为“第3页”。做法为:”在页脚中插入页码,并选中(图2),点开页码下拉菜单(图1),在“页码编号”设置(图3)。搞定。

  • 2. 如果是第1-2页不要页码,则用分节方式,插入两节,并取消页眉页脚设置中的“链接到上一节”功能,第三节插入页码,如上设置即可。



这个具体的你可以和我去后盾人平台看看相关高清教材,这样不就会了,希望能帮到你,给个采纳吧谢谢(ノಥ益ಥ)

相关阅读

关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网