PHPackages                             opencat/filter-docx - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. opencat/filter-docx

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

opencat/filter-docx
===================

DOCX (.docx) file filter for the OpenCAT Framework

00PHP

Since May 9Pushed 1mo agoCompare

[ Source](https://github.com/shaikhammar/opencat-filter-docx)[ Packagist](https://packagist.org/packages/opencat/filter-docx)[ RSS](/packages/opencat-filter-docx/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

catframework/filter-docx
========================

[](#catframeworkfilter-docx)

Microsoft Word DOCX file filter for the [CAT Framework](https://github.com/shaikhammar/cat-framework).

Installation
------------

[](#installation)

```
composer require catframework/filter-docx
```

Requires `ext-dom`, `ext-libxml`, and `ext-zip`.

Usage
-----

[](#usage)

```
use CatFramework\FilterDocx\DocxFilter;

$filter = new DocxFilter();

// Extract translatable segments
$document = $filter->extract('report.docx', 'en', 'fr');

foreach ($document->getSegmentPairs() as $pair) {
    $pair->target = new Segment('seg-t', [$translatedText]);
}

// Write the translated DOCX
$filter->rebuild($document, 'report.fr.docx');
```

What gets extracted
-------------------

[](#what-gets-extracted)

Each non-empty `` paragraph in the document is one segment. Adjacent runs with identical formatting (``) are merged before extraction, reducing the number of inline code placeholders a translator sees.

**Extracted locations** (in order):

1. `word/document.xml` — main body
2. `word/header1.xml` … `word/header10.xml` — headers
3. `word/footer1.xml` … `word/footer10.xml` — footers
4. `word/footnotes.xml`, `word/endnotes.xml` — notes

Formatting runs within a paragraph become `InlineCode` pairs so translators see `{}translated text{}` instead of raw XML.

RTL support
-----------

[](#rtl-support)

When the target language is Arabic, Hebrew, Farsi, Urdu, or another RTL language, `` is injected into each run's `` and `` is added to paragraph properties on rebuild.

Supported RTL language prefixes: `ar`, `he`, `fa`, `ur`, `yi`, `dv`, `ps`, `sd`.

Skeleton format
---------------

[](#skeleton-format)

The skeleton is a temporary DOCX file written to the system temp directory at extract time:

```
['path' => '/tmp/cat-.skl']
```

The skeleton file is a copy of the original DOCX ZIP with paragraph content replaced by `{{SEG:NNN}}` tokens. **Do not delete it** between `extract()` and `rebuild()` calls. It is not automatically cleaned up.

Limitations
-----------

[](#limitations)

- **Tables**: cell text is extracted as individual paragraph segments; table structure is preserved in the skeleton.
- **Text boxes and shapes**: content inside drawing anchors is not currently extracted.
- **Comments and revisions**: tracked changes and comment text are not extracted.
- **Skeleton lifetime**: the `.skl` temp file must survive between `extract()` and `rebuild()`. For long-lived workflows, persist `$document->skeleton['path']` and ensure the file is not cleaned up by the OS.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance61

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c6b9044413071860fd6199e56c661a24f449797b77a1b130f0df7e98be8481f4?d=identicon)[shaikhammar](/maintainers/shaikhammar)

---

Top Contributors

[![actions-user](https://avatars.githubusercontent.com/u/65916846?v=4)](https://github.com/actions-user "actions-user (3 commits)")

### Embed Badge

![Health badge](/badges/opencat-filter-docx/health.svg)

```
[![Health](https://phpackages.com/badges/opencat-filter-docx/health.svg)](https://phpackages.com/packages/opencat-filter-docx)
```

###  Alternatives

[symfony/ux-vue

Integration of Vue.js in Symfony

35917.9k4](/packages/symfony-ux-vue)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
