{"id":13405360,"url":"https://github.com/spatie/pdf-to-text","last_synced_at":"2025-05-13T19:18:12.425Z","repository":{"id":37733879,"uuid":"48845831","full_name":"spatie/pdf-to-text","owner":"spatie","description":"Extract text from a pdf","archived":false,"fork":false,"pushed_at":"2025-01-27T09:28:24.000Z","size":122,"stargazers_count":920,"open_issues_count":0,"forks_count":125,"subscribers_count":18,"default_branch":"main","last_synced_at":"2025-05-06T15:49:58.310Z","etag":null,"topics":["pdf","pdf-converter","php","text"],"latest_commit_sha":null,"homepage":"https://freek.dev/348-a-package-to-extract-text-from-a-pdf","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/spatie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"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,"zenodo":null},"funding":{"custom":"https://spatie.be/open-source/support-us"}},"created_at":"2015-12-31T10:28:39.000Z","updated_at":"2025-04-27T08:37:30.000Z","dependencies_parsed_at":"2024-01-16T21:30:51.402Z","dependency_job_id":"f3e1b092-3fbe-48de-8d7c-a9f89c29892f","html_url":"https://github.com/spatie/pdf-to-text","commit_stats":{"total_commits":111,"total_committers":18,"mean_commits":6.166666666666667,"dds":0.5855855855855856,"last_synced_commit":"70cc85df2cd145291fe1e0a35260da246b88ca7d"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fpdf-to-text","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fpdf-to-text/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fpdf-to-text/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fpdf-to-text/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spatie","download_url":"https://codeload.github.com/spatie/pdf-to-text/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252973606,"owners_count":21834104,"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":["pdf","pdf-converter","php","text"],"created_at":"2024-07-30T19:01:59.736Z","updated_at":"2025-05-13T19:18:12.403Z","avatar_url":"https://github.com/spatie.png","language":"PHP","funding_links":["https://spatie.be/open-source/support-us"],"categories":["PHP","PYTHON"],"sub_categories":[],"readme":"# Extract text from a pdf\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/pdf-to-text.svg?style=flat-square)](https://packagist.org/packages/spatie/pdf-to-text)\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/spatie/pdf-to-text/run-tests.yml?label=tests)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![Quality Score](https://img.shields.io/scrutinizer/g/spatie/pdf-to-text.svg?style=flat-square)](https://scrutinizer-ci.com/g/spatie/pdf-to-text)\n[![Total Downloads](https://img.shields.io/packagist/dt/spatie/pdf-to-text.svg?style=flat-square)](https://packagist.org/packages/spatie/pdf-to-text)\n\nThis package provides a class to extract text from a pdf.\n\n```php\nuse Spatie\\PdfToText\\Pdf;\n\necho Pdf::getText('book.pdf'); //returns the text from the pdf\n```\n\nSpatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).\n\n## Support us\n\n[\u003cimg src=\"https://github-ads.s3.eu-central-1.amazonaws.com/pdf-to-text.jpg?t=1\" width=\"419px\" /\u003e](https://spatie.be/github-ad-click/pdf-to-text)\n\nWe invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).\n\nWe highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).\n\n## Requirements\n\nBehind the scenes this package leverages [pdftotext](https://en.wikipedia.org/wiki/Pdftotext). You can verify if the binary installed on your system by issueing this command:\n\n```bash\nwhich pdftotext\n```\n\nIf it is installed it will return the path to the binary.\n\nTo install the binary you can use this command on Ubuntu or Debian:\n\n```bash\napt-get install poppler-utils\n```\n\nOn a mac you can install the binary using brew\n\n```bash\nbrew install poppler\n```\n\nIf you're on RedHat, CentOS, Rocky Linux or Fedora use this:\n\n```bash\nyum install poppler-utils\n```\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require spatie/pdf-to-text\n```\n\n## Usage\n\nExtracting text from a pdf is easy.\n\n```php\n$text = (new Pdf())\n    -\u003esetPdf('book.pdf')\n    -\u003etext();\n```\n\nOr easier:\n\n```php\necho Pdf::getText('book.pdf');\n```\n\nBy default the package will assume that the `pdftotext` command is located at `/usr/bin/pdftotext`.\nIf it is located elsewhere pass its binary path to constructor\n\n```php\n$text = (new Pdf('/custom/path/to/pdftotext'))\n    -\u003esetPdf('book.pdf')\n    -\u003etext();\n```\n\nor as the second parameter to the `getText` static method:\n\n```php\necho Pdf::getText('book.pdf', '/custom/path/to/pdftotext');\n```\n\nSometimes you may want to use [pdftotext options](https://linux.die.net/man/1/pdftotext). To do so you can set them up using the `setOptions` method.\n\n```php\n$text = (new Pdf())\n    -\u003esetPdf('table.pdf')\n    -\u003esetOptions(['layout', 'r 96'])\n    -\u003etext()\n;\n```\n\nor as the third parameter to the `getText` static method:\n\n```php\necho Pdf::getText('book.pdf', null, ['layout', 'opw myP1$$Word']);\n```\n\nPlease note that successive calls to `setOptions()` will overwrite options passed in during previous calls. \n\nIf you need to make multiple calls to add options (for example if you need to pass in default options when creating \nthe `Pdf` object from a container, and then add context-specific options elsewhere), you can use the `addOptions()` method:\n \n ```php\n $text = (new Pdf())\n     -\u003esetPdf('table.pdf')\n     -\u003esetOptions(['layout', 'r 96'])\n     -\u003eaddOptions(['f 1'])\n     -\u003etext()\n ;\n ```\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information about what has changed recently.\n\n## Testing\n\n```bash\n composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.\n\n## Security\n\nIf you've found a bug regarding security please mail [security@spatie.be](mailto:security@spatie.be) instead of using the issue tracker.\n\n## Credits\n\n- [Freek Van der Herten](https://github.com/freekmurze)\n- [All Contributors](../../contributors)\n\n## About Spatie\n\nSpatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).\n\n## License\n\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%2Fspatie%2Fpdf-to-text","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspatie%2Fpdf-to-text","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Fpdf-to-text/lists"}