{"id":15030121,"url":"https://github.com/nilgems/laravel-textract","last_synced_at":"2025-04-09T20:41:14.204Z","repository":{"id":38094394,"uuid":"502025392","full_name":"NilGems/laravel-textract","owner":"NilGems","description":"A text extraction package for Laravel","archived":false,"fork":false,"pushed_at":"2024-05-03T12:37:38.000Z","size":4349,"stargazers_count":18,"open_issues_count":3,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T22:37:12.040Z","etag":null,"topics":["extractor","html","image","laravel","laravel-package","ms-excel","ms-word","php8","text"],"latest_commit_sha":null,"homepage":"","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/NilGems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2022-06-10T11:55:57.000Z","updated_at":"2025-03-07T01:24:22.000Z","dependencies_parsed_at":"2024-09-28T20:40:46.533Z","dependency_job_id":"d1841048-dd92-4ca1-8b05-2cd96c9a6428","html_url":"https://github.com/NilGems/laravel-textract","commit_stats":{"total_commits":34,"total_committers":2,"mean_commits":17.0,"dds":"0.11764705882352944","last_synced_commit":"c5317a974201ddd759bb9c82933b8d15a3caeb17"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NilGems%2Flaravel-textract","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NilGems%2Flaravel-textract/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NilGems%2Flaravel-textract/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NilGems%2Flaravel-textract/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NilGems","download_url":"https://codeload.github.com/NilGems/laravel-textract/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248109755,"owners_count":21049366,"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","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":["extractor","html","image","laravel","laravel-package","ms-excel","ms-word","php8","text"],"created_at":"2024-09-24T20:12:30.448Z","updated_at":"2025-04-09T20:41:14.177Z","avatar_url":"https://github.com/NilGems.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Packagist](https://img.shields.io/packagist/v/nilgems/laravel-textract)](https://packagist.org/packages/nilgems/laravel-textract)\n# Laravel Textract\nA [Laravel](https://laravel.com) package to extract text from files like DOC, Excel, Image, Pdf and more.\n\n# Versions and compatibility\n\n- [Laravel 10](https://laravel.com) or higher is required.\n- [Php 8.2]() or higher is required\n\n### Supported file formats\nFollowing file formats is supported currently. You need to install proper extensions\nto your server to work with all the following extension related files. The package will \ncheck file content MIME type before execute.\n- **HTML**\n- **TEXT**\n- **DOC**\n- **DOCX**\n- **XLS**, **XLSX**, **XLSM**, **XLTX**, **XLTM**, **XLT**\n- **CSV**\n- **PDF**\n- **Image**\n  - _jpeg_\n  - _png_\n  - _gif_\n- **ODT**\n- **ODS**\n- **RTF**\n- **PPTX** (NEW)\n\n**We are working hard to make this laravel plugin useful. If you found any issue please add a post on discussion.**\n\n### Installation\n\n``` \ncomposer require nilgems/laravel-textract\n```\nOnce installed you can do stuff like this:\n```\n# Run the extractor\n$output = Textract::run('/path/to/file.extension');\n\n# Display the extracted text\necho $output-\u003etext;\n\n# Display the extracted text word count\necho $output-\u003eword_count;\n\n# Display the extracted text with direct string conversion\necho (string) $output;\n```\nRun the extractor to any supported file:\n```\nTextract::run(string $file_path, [string $job_id],[TesseractOcrOptions $extra_data]);\n```\n|   Option    |           Type            |   Default value    | Required |                                                                                                          Description                                                                                                           |\n|:-----------:|:-------------------------:|:------------------:|:--------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|\n| $file_path  |       ```String```        | _No default value_ |   Yes    |                                                                                              Text extractable file absolute path.                                                                                              |\n|   $job_id   |       ```String```        |     ```NULL```     |    No    |                                                        It's a optional parameter. Extraction **job id**. If this option is blank the plugin will auto create the **ID**                                                        |\n| $extra_data | ```TesseractOcrOptions``` |     ```NULL```     |    No    | It's a optional parameter. To pass extra parameter. If you are extracting a image file, you can mention languages and more by this ```Nilgems\\PhpTextract\\ExtractorService\\Ocr\\Contracts\\TesseractOcrOptions``` **parameter**. |\n\n### Configuration\n\n- You can add **provider** in ```app.php``` under the ```config``` folder of your\n[Laravel](https://laravel.com) project. It's optional, the package automatically load the service provider in your application. \n  ```\n  'providers' =\u003e [\n    ...\n    Nilgems\\PhpTextract\\Providers\\ServiceProvider,\n    ...\n  ]\n  ```\n- Add **alias** in ```app.php``` under the ```config``` folder of your\n  [Laravel](https://laravel.com) project. It's optional, the package automatically load the ```facade``` in your application.\n  ```\n  'aliases' =\u003e [\n    ...\n    'Textract' =\u003e Nilgems\\PhpTextract\\Textract::class,\n    ...\n  ]\n  ```\n- To publish the ```config``` file, run:\n  ```\n  php artisan vendor:publish --tag=textract\n  ```\n### Example \n\n##### Example 1: \nYou can extract text from supported file format.\n\nIt is recommended to use the extractor with [Laravel Queue Job](https://laravel.com/docs/9.x/queues#creating-jobs) from better performance. \u003cbr /\u003e\u003cbr /\u003e\nIn ```php``` there have a restriction of execution time and memory limit defined in ```php.ini``` file with the option ```max_execution_time``` and ```memory_limit```. If file size is big, the process may kill forcefully when exceed the limit. You can use ```queue - database/redis``` or ```Laravel horizon``` to run the process in background.\n```\n........\nRoute::get('/textract', function(){\n    return Textract::run('/path/to/image/example.png');\n});\n........\n```\n\n##### Example 2:\nIf you need to specify languages in image file for better extraction output from image file.\n```\n........\nRoute::get('/textract', function(){\n    return Textract::run('/path/to/image/example.png', null, [\n      'lang' =\u003e ['eng', 'jpn', 'spa']\n    ]);\n});\n........\n```\n### Dependencies\n- To enable the image extraction feature you need to install [Tesseract OCR](https://github.com/tesseract-ocr/tesseract)\n- To enable the PDF extraction feature you need to install [pdftotext](http://www.xpdfreader.com/download.html)\n- To work properly, your server must have following php extensions installed -\n  - **ext-fileinfo**\n  - **ext-zip**\n  - **ext-gd** or **ext-imagick**\n  - **ext-xml**\n### Tesseract OCR Installation\n#### \u003cimg src=\"https://raw.githubusercontent.com/NilGems/laravel-textract/master/blobs/ubuntu.png\" width=\"12\"  alt=\"Ubuntu\" /\u003e Ubuntu\n- Update the system: ```sudo apt update```\n- Add Tesseract OCR 5 PPA to your system: ```sudo add-apt-repository ppa:alex-p/tesseract-ocr-devel```\n- Install Tesseract on Ubuntu 20.04 | 18.04: ```sudo apt install -y tesseract-ocr```\n- Once installation is complete update your system: ```sudo apt update```\n- Verify the installation: ```tesseract --version```\n#### \u003cimg src=\"https://raw.githubusercontent.com/NilGems/laravel-textract/master/blobs/windows.png\" width=\"12\"  alt=\"Ubuntu\" /\u003e Windows\n- There are many [ways](https://github.com/tesseract-ocr/tesseract/wiki#windows) to install [Tesseract OCR](https://github.com/tesseract-ocr/tesseract) on your system, but if you just want something quick to get up and running, I recommend installing the [Capture2Text](https://chocolatey.org/packages/capture2text) package with [Chocolatey](https://chocolatey.org/). \n- Choco installation: ```choco install capture2text --version 5.0```\n\n**Note: Recent versions of [Capture2Text](https://chocolatey.org/packages/capture2text) stopped shipping the ```tesseract``` binary**\n\n### PdfToText Installation\n#### \u003cimg src=\"https://raw.githubusercontent.com/NilGems/laravel-textract/master/blobs/ubuntu.png\" width=\"12\"  alt=\"Ubuntu\" /\u003e Ubuntu\n- Update the system: ```sudo apt update```\n- Install PdfToText on Ubuntu 20.04 | 18.04: ```sudo apt-get install poppler-utils```\n- Verify the installation: ```pdftotext -v```\n#### \u003cimg src=\"https://raw.githubusercontent.com/NilGems/laravel-textract/master/blobs/windows.png\" width=\"12\"  alt=\"Ubuntu\" /\u003e Windows\n  - Sorry but ```pdftotext``` available via [poppler](https://poppler.freedesktop.org/) and the [poppler](https://poppler.freedesktop.org/) is not available yet for windows. But you can install and [use the library by windows linux sub-system WLS](https://towardsdatascience.com/poppler-on-windows-179af0e50150). Alternatively, you can install [Laravel Homestead](https://laravel.com/docs/9.x/homestead) in your project and using vagrant virtualization you can run the project in ubuntu virtual server.\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n\n---\n## 💻 Tech Stack\n![CSS3](https://img.shields.io/badge/css3-%231572B6.svg?style=plastic\u0026logo=css3\u0026logoColor=white) ![PHP](https://img.shields.io/badge/php-%23777BB4.svg?style=plastic\u0026logo=php\u0026logoColor=white) ![HTML5](https://img.shields.io/badge/html5-%23E34F26.svg?style=plastic\u0026logo=html5\u0026logoColor=white) ![JavaScript](https://img.shields.io/badge/javascript-%23323330.svg?style=plastic\u0026logo=javascript\u0026logoColor=%23F7DF1E) ![AWS](https://img.shields.io/badge/AWS-%23FF9900.svg?style=plastic\u0026logo=amazon-aws\u0026logoColor=white) ![Vue.js](https://img.shields.io/badge/vuejs-%2335495e.svg?style=plastic\u0026logo=vuedotjs\u0026logoColor=%234FC08D) ![Vuetify](https://img.shields.io/badge/Vuetify-1867C0?style=plastic\u0026logo=vuetify\u0026logoColor=AEDDFF) ![NPM](https://img.shields.io/badge/NPM-%23000000.svg?style=plastic\u0026logo=npm\u0026logoColor=white) ![jQuery](https://img.shields.io/badge/jquery-%230769AD.svg?style=plastic\u0026logo=jquery\u0026logoColor=white) ![Express.js](https://img.shields.io/badge/express.js-%23404d59.svg?style=plastic\u0026logo=express\u0026logoColor=%2361DAFB) ![Laravel](https://img.shields.io/badge/laravel-%23FF2D20.svg?style=plastic\u0026logo=laravel\u0026logoColor=white) ![NuxtJS](https://img.shields.io/badge/Nuxt-black?style=plastic\u0026logo=nuxt.js\u0026logoColor=white) ![Socket.io](https://img.shields.io/badge/Socket.io-black?style=plastic\u0026logo=socket.io\u0026badgeColor=010101) ![Apache](https://img.shields.io/badge/apache-%23D42029.svg?style=plastic\u0026logo=apache\u0026logoColor=white) ![MariaDB](https://img.shields.io/badge/MariaDB-003545?style=plastic\u0026logo=mariadb\u0026logoColor=white) ![MongoDB](https://img.shields.io/badge/MongoDB-%234ea94b.svg?style=plastic\u0026logo=mongodb\u0026logoColor=white) ![MySQL](https://img.shields.io/badge/mysql-%2300f.svg?style=plastic\u0026logo=mysql\u0026logoColor=white) ![SQLite](https://img.shields.io/badge/sqlite-%2307405e.svg?style=plastic\u0026logo=sqlite\u0026logoColor=white) ![Inkscape](https://img.shields.io/badge/Inkscape-e0e0e0?style=plastic\u0026logo=inkscape\u0026logoColor=080A13) ![Jira](https://img.shields.io/badge/jira-%230A0FFF.svg?style=plastic\u0026logo=jira\u0026logoColor=white) ![Vagrant](https://img.shields.io/badge/vagrant-%231563FF.svg?style=plastic\u0026logo=vagrant\u0026logoColor=white)\n\n---\n[![](https://visitcount.itsvg.in/api?id=NilGems\u0026icon=0\u0026color=0)](https://visitcount.itsvg.in)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnilgems%2Flaravel-textract","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnilgems%2Flaravel-textract","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnilgems%2Flaravel-textract/lists"}