skyh13/php-rtflex
Composer 安装命令:
composer require skyh13/php-rtflex
包简介
A simple library to allow parsing of RTF files and strings. Forked from silvermine/php-rtflex.
README 文档
README
RTFLex is a simple lexer / tokenizer for RTF formatted data.
Example Usage
RTFLex allows you to easily extract plain text from an RTF formatted file, or a text string containing RTF formatting. Here's how you would read an RTF file:
require_once "rtflex/RTFLexer.php";
use RTFLex\io\StreamReader;
use RTFLex\tokenizer\RTFTokenizer;
use RTFLex\tree\RTFDocument;
$reader = new StreamReader('/path/to/myFile.rtf');
$tokenizer = new RTFTokenizer($reader);
$doc = new RTFDocument($tokenizer);
echo $doc->extractText();
While RTFLex uses namespaces to organize it's inner-workings, it also provides a simple, global, front-end class for easy of use. This accomplishes the same as the above code:
require_once "rtflex/RTFLexer.php";
$doc = RTFLexer::file('/path/to/myFile.rtf');
echo $doc->extractText();
RTFLex also lets you easily extract hidden metadata from an RTF file. Take, for example, the follow RTF header:
{\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf370
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\info
{\title Sample Title}
{\subject Sample Subject}
{\author Craig Weber}
{\*\company silvermine}
{\*\copyright 2013 silvermine.}}\margl1440\margr1440\vieww10800\viewh8400\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
...
Using the RTFDocument class, it's easy to extract those field.
$doc = RTFLexer::file('/path/to/myFile.rtf');
echo $doc->extractMetadata('title'); // => "Sample Title"
echo $doc->extractMetadata('copyright'); // => "2013 silvermine."
skyh13/php-rtflex 适用场景与选型建议
skyh13/php-rtflex 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 33.12k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2015 年 08 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 skyh13/php-rtflex 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 skyh13/php-rtflex 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 33.12k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2015-08-20