{"id":22278034,"url":"https://github.com/enflow/document-replacer","last_synced_at":"2026-04-21T09:01:36.839Z","repository":{"id":42574656,"uuid":"183407062","full_name":"enflow/document-replacer","owner":"enflow","description":"Modify docx templates and convert them to PDF","archived":false,"fork":false,"pushed_at":"2025-02-22T19:50:12.000Z","size":97,"stargazers_count":8,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-08T09:35:57.386Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/enflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":"https://enflow.nl/contact"}},"created_at":"2019-04-25T09:57:35.000Z","updated_at":"2025-02-22T19:49:19.000Z","dependencies_parsed_at":"2024-03-18T23:30:36.664Z","dependency_job_id":"a0b10894-2756-4baa-9aa9-46a578255dbe","html_url":"https://github.com/enflow/document-replacer","commit_stats":{"total_commits":51,"total_committers":3,"mean_commits":17.0,"dds":"0.17647058823529416","last_synced_commit":"5a2cab2046895432ae570d9bf48e300bac2c0664"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/enflow/document-replacer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enflow%2Fdocument-replacer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enflow%2Fdocument-replacer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enflow%2Fdocument-replacer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enflow%2Fdocument-replacer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/enflow","download_url":"https://codeload.github.com/enflow/document-replacer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enflow%2Fdocument-replacer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267563486,"owners_count":24108097,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-03T15:12:39.094Z","updated_at":"2026-04-21T09:01:31.792Z","avatar_url":"https://github.com/enflow.png","language":"PHP","funding_links":["https://enflow.nl/contact"],"categories":[],"sub_categories":[],"readme":"# Modify docx templates and convert them to PDF\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/enflow/document-replacer.svg?style=flat-square)](https://packagist.org/packages/enflow/document-replacer)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![Build Status](https://img.shields.io/travis/enflow-nl/document-replacer/master.svg?style=flat-square)](https://travis-ci.org/spatie/document-replacer)\n[![Total Downloads](https://img.shields.io/packagist/dt/enflow/document-replacer.svg?style=flat-square)](https://packagist.org/packages/enflow/document-replacer)\n\nThe `enflow/document-replacer` package provides a easy way to modify docx templates, replace text and save it. Adds the ability to export it to PDF trough unoserver/unoconvert.\n\n## Installation\nYou can install the package via composer:\n\n``` bash\ncomposer require enflow/document-replacer\n```\n\n## PDF conversion\nThis package comes with an implementation to convert docx templates to PDF using unoserver. You can install this on your machine globally using:\n```\nsudo add-apt-repository ppa:libreoffice/ppa\nsudo apt install libreoffice\nsudo pip install unoserver\n```\n\n## Converters\nIt's highly recommend using the new `unoconvert` converter. If you are unable to upgrade, we still provide the deprecated `UnoconvConverter` for the time being. `UnoconvConverter` is deprecated and will be removed in 3.0.\n\n## Server\nUnoserver works together with unoconvert. Unoserver runs as a daemon on the server, and unoconvert connects through it to pass the files. To see why this is more efficient, see https://github.com/unoconv/unoserver/#overview\n\nStart the server with:\n`unoserver --daemon`\n\nIt's recommended setting this up with a server like supervisord, without the `--daemon` flag, to auto restart the process if needed.\n\n## Usage\n``` php\nuse Enflow\\DocumentReplacer\\DocumentReplacer;\n\nDocumentReplacer::template('filename.docx')\n    -\u003econverter(UnoserverConverter::class)\n    -\u003ereplace([\n        '${user}' =\u003e 'Michel',\n        '${address.city}' =\u003e 'Alphen aan den Rijn',\n        '${company}' =\u003e 'Enflow',\n    ])\n    -\u003esave('document.pdf');\n```\n\n#### Images\nIf you wish to replace images in your document, you can pass the `Image` class to the replacement array like this:\n\n```php\nuse Enflow\\DocumentReplacer\\DocumentReplacer;\nuse Enflow\\DocumentReplacer\\ValueTypes\\Image;\n\nDocumentReplacer::template('filename.docx')\n    -\u003econverter(UnoconvConverter::class)\n    -\u003ereplace([\n        '${primary}' =\u003e Image::forPath('image.png'),\n        '${second}' =\u003e Image::forBase64('iVBORw0KGgoA...'),\n    ])\n    -\u003esave('document.pdf');\n```\n\nThe search-pattern model for images can be like:\n- ``${search-image-pattern}``\n- ``${search-image-pattern:[width]:[height]:[ratio]}``\n- ``${search-image-pattern:[width]x[height]}``\n- ``${search-image-pattern:size=[width]x[height]}``\n- ``${search-image-pattern:width=[width]:height=[height]:ratio=false}``\nWhere:\n- [width] and [height] can be just numbers or numbers with measure, which supported by Word (cm|mm|in|pt|pc|px|%|em|ex)\n- [ratio] uses only for ``false``, ``-`` or ``f`` to turn off respect aspect ration of image. By default template image size uses as 'container' size.\n\nMore info can be found in the [`PHPWord` documentation](https://github.com/PHPOffice/PHPWord/blob/develop/docs/templates-processing.rst#setimagevalue)\n\n## Non-default server options\nRunning the server on non-default options (IP 127.0.0.1 / port 2002)? You can pass along the interface and port to the `UnoserverConverter`:\n\n``` php\nDocumentReplacer::template('filename.docx')\n    -\u003econverter(UnoserverConverter::class, [\n        'interface' =\u003e '192.168.0.1',\n        'port' =\u003e 1533,\n    ])\n```\n\n## Testing\n``` bash\n$ composer test\n```\n\n## Contributing\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security\nIf you discover any security related issues, please email michel@enflow.nl instead of using the issue tracker.\n\n## Credits\n- [Michel Bardelmeijer](https://github.com/mbardelmeijer)\n- [All Contributors](../../contributors)\n\n## About Enflow\nEnflow is a digital creative agency based in Alphen aan den Rijn, Netherlands. We specialize in developing web applications, mobile applications and websites. You can find more info [on our website](https://enflow.nl/en).\n\n## License\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenflow%2Fdocument-replacer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenflow%2Fdocument-replacer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenflow%2Fdocument-replacer/lists"}