【问题标题】:PHP how to remove author metadata from docxPHP如何从docx中删除作者元数据
【发布时间】:2016-02-02 09:49:55
【问题描述】:

在 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 文件?

【问题讨论】:

  • rrmdir ?当然应该是rmdir
  • 是的,对不起,这是我的错误,谢谢!但是,我不认为这是主要问题

标签: php zip metadata docx php-zip-archive


【解决方案1】:

我不知道 php,但我认为问题是您必须在 $unzipped 文件夹内进行压缩,而不是文件夹本身。所以一种递归的“$unzipped/*”作为源而不是“$unzipped”。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-03-05
    • 2011-01-27
    • 2014-01-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多