我正试图以编程方式使用PHP打开一个word-file (.docx)。这个字文件是用密码保护和加密的,所以如果不提供密码,就不能显示它的内容。我当然知道密码。
但是,我如何通过提供密码来用PHP打开这个word文件呢?
唯一至少提到密码保护的PHP库是伟大的PhpOffice/PhpWord,但它不支持打开密码保护的文件:https://github.com/PHPOffice/PHPWord/issues/357。
请注意,在防止不必要的更改的密码保护和-这是我的情况-保护它防止未经授权的打开之间有一个细微的区别。
提亚
发布于 2021-01-24 15:10:10
我欢迎你来看看我的PHPDecryptXLSXWithPassword回购。
首先用密码解密文件,然后与PHPWord一起使用解密文件。
下面是一个示例:
require_once('PHPDecryptXLSXWithPassword.php');
$encryptedFilePath = '../path/to/encrypted/file.docx';
$password = 'mypassword'; // password to "open" the file
$decryptedFilePath = '../path/to/decrypted/file.docx';
decrypt($encryptedFilePath, $password, $decryptedFilePath);
// now you can use PHPWord with $decryptedFilePath注意:这是一个实验代码,所以要谨慎使用。不要在生产中使用!
https://stackoverflow.com/questions/51512890
复制相似问题