在PHP中,我要从DOCX文件中删除作者元数据。首先,我解压缩了文档,在使用XML阅读器库编辑作者元数据设置后,它已经空了。
$file = 'document.docx';
$filename = 'path/'.$file;
// Unzip the docx
$unzipped = md5($filename);
if (file_exists($unzipped)) {
rmdir($unzipped);
mkdir($unzipped);
}
$zip = new ZipArchive;
$res = $zip->open($filename);
if ($res === true) {
extractFolder($zip, "word/media", $unzipped);
$zip->extractTo($unzipped);
$zip->close();
} else {
die("The docx file appears to be corrupt (i.e. it can't be opened using Zip).\n");
}
当我尝试重新压缩文档时出现问题。事实上,当重新压缩完成后,当我在Word中打开它时,docx文件似乎已损坏。
create_docx($unzipped,'_zips/'.$file );
如何修改作者元数据(将文档设置为匿名)并保存正确的docx文件?
答案 0 :(得分:0)
我不知道php,但我认为问题是你必须压缩文件夹$解压缩,而不是文件夹本身。所以一种递归" $解压缩/ *"作为来源而不是" $解压缩"。