Forum


Replies: 6   Views: 241
Indexer: check or exclude externals resources
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 28-11-2024 - 09:38

Hello,

The OOXML standard handles all external (linked) images using the same tag and attributes. For example an external URL or external image file.

If you open a DOCX with inaccessible external resources with MS Word and other DOCX readers, they warn about the missing resources. The current stable version of Indexer works in the same way, and file_get_contents throws a PHP Warning when an external resource is not accessible.

Please note that the information returned by Indexer (arrays) can be unset to filter sensitive information from the document if you need to display some information to external users.
You can use getDocxPathQueryInfo to check if a DOCX contains external image resources and removeWordContent to remove them:

$docx = new CreateDocxFromTemplate('template.docx');

// remove external (linked) images
$referenceNode = array(
    'customQuery' => '//w:drawing[.//@r:link]',
);
$docx->removeWordContent($referenceNode);
$docx->createDocx('template_new');

We have added a task to the dev team to improve Indexer for this specific case.

To limit the files in the fs that PHP can access, you can use open_basedir (https://www.php.net/manual/en/ini.core.php#ini.open-basedir) in the PHP configuration.

Regards.