{"id":16539551,"url":"https://github.com/tyru/php-rtf-parser","last_synced_at":"2025-04-11T06:36:56.483Z","repository":{"id":66794698,"uuid":"142262447","full_name":"tyru/php-rtf-parser","owner":"tyru","description":"PHP Rich Text Format Parser","archived":false,"fork":false,"pushed_at":"2018-07-25T09:03:03.000Z","size":15,"stargazers_count":4,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T04:32:38.808Z","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/tyru.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2018-07-25T07:16:44.000Z","updated_at":"2022-11-09T18:57:00.000Z","dependencies_parsed_at":"2023-04-15T17:18:11.291Z","dependency_job_id":null,"html_url":"https://github.com/tyru/php-rtf-parser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyru%2Fphp-rtf-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyru%2Fphp-rtf-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyru%2Fphp-rtf-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyru%2Fphp-rtf-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tyru","download_url":"https://codeload.github.com/tyru/php-rtf-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248358533,"owners_count":21090400,"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":[],"created_at":"2024-10-11T18:49:38.491Z","updated_at":"2025-04-11T06:36:56.474Z","avatar_url":"https://github.com/tyru.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Rich Text Format Parser\n\nRun frontend script `extract-text-from-rtf.php` to extract only the text in rtf file.\n\n```\nphp extract-text-from-rtf.php -f sample.rtf [-i \u003cinput encoding\u003e] [-o \u003coutput encoding\u003e]\n```\n\nHere are the default input/output encodings:\n\n| OS      | input | output               |\n| ------- | ----- | -------------------- |\n| Windows | guess | CP932                |\n| Others  | guess | (detect from $LANG)  |\n\nThe input encoding is the encoding of rtf file.  It is normally current code\npage of Windows on which a user created the file.  For example, Windows in\nJapanese version, `CP932`.  If input encoding is `guess`, it tries to find\n`\\ansicpg` control word.  `\\ansicpg` declares the default character set used in\nthe document unless it is \\ansi (the default).  if `\\ansicpgN` (N is parameter)\nis found, it returns encoding string `\"cp\u003cN\u003e\"`.  For example, `\\ansicpg932` is\nfound, it returns string `\"cp932\"`.  The library user can get the encoding by\n`RtfParser\\Document#getEncoding()` method.\n\nThe output encoding is the encoding of standard output.  For example, Windows in\nJapanese version, `CP932` (cmd.exe encoding).  Of course you can encode to UTF-8\nlike `-o UTF-8`.  By default, on non-Windows platform, output encoding is\ndetected by `LANG` environment variable. if it fails, 'UTF-8' is the default\nvalue.\n\nThese arguments are passed to `mb_convert_encoding()` function if both encodings are not same.\n\n# RtfParser\n\n```php\n$scanner = new RtfParser\\Scanner($text);\n$parser = new RtfParser\\Parser($scanner);\n$text = '';\n$doc = $parser-\u003eparse();\nforeach ($doc-\u003echildNodes() as $node) {\n  $text .= $node-\u003etext();\n}\necho $text;\n```\n\n`$parser-\u003eparse()` returns `RtfParser\\Document` instance.  `$doc-\u003echildNodes()`\nreturns array of `RtfParser\\Node\\Node`.  Currently [`RtfParser\\Node\\Node`\ninterface](https://github.com/tyru/php-rtf-parser/blob/master/src/Node/Node.php)\nonly supports `text()` and `name()` method.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyru%2Fphp-rtf-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftyru%2Fphp-rtf-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyru%2Fphp-rtf-parser/lists"}