php获取word图片大小,使用php 读取带有图像的Ms word文档

参见英文答案 > reading docx (Office Open XML) in PHP                                    7个

我有一大堆代码用于阅读MS Office Word文档.

它只读取文本而不是所有内容.

function read_file_docx($filename){

$striped_content = '';

$content = '';

if(!$filename || !file_exists($filename)) return false;

$zip = zip_open($filename);

if (!$zip || is_numeric($zip)) return false;

while ($zip_entry = zip_read($zip)) {

if (zip_entry_open($zip, $zip_entry) == FALSE) continue;

if (zip_entry_name($zip_entry) != "word/document.xml") continue;

$content .= zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));

zip_entry_close($zip_entry);

}

zip_close($zip);

$content = str_replace('', " ", $content);

$content = str_replace('', "\r\n", $content);

$striped_content = strip_tags($content);

return $striped_content;

}

$filename =“customers.docx”;

$content = read_file_docx($filename);

if($content !== false) {

echo nl2br($content);

}

else {

echo 'Couldn\'t the file. Please check that file.';

}

?>

我想要阅读图像,图表和所有内容,并将其显示在网页中.

解决方法:

我认为您应该首先使用命令行Open Office或者将您的doc文档更改为pdf

自由办公室.

与自由办公室,它将是:

libreoffice --headless --convert-to pdf your_file_name.doc

然后使用pdf.js(https://github.com/mozilla/pdf.js/)在您的网站上显示文档(您不需要adobe reader)

标签:php,ms-word,ms-office,filereader

来源: https://codeday.me/bug/20190624/1281686.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值