没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
原创|产品更新|编辑:况鱼杰|2019-12-23 11:39:12.390|阅读 657 次
概述:为了改善API的工作效率并简化开发人员的使用,从头开始对GroupDocs.Parser的架构进行了改进。此次更新将会提供GroupDocs.Parser for Java 19.11改进和简化的API。
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
GroupDocs.Parser for Java是文本,图像和元数据提取器API,用于构建支持解析原始,结构化和格式化文本的业务应用程序。它还允许检索支持格式的文件元数据。
自GroupDocs.Parser for Java API进入市场,它就成为了功能强大的文档解析器API之一,它可以解析和读取常用格式的文字处理文档,电子表格,演示文稿,电子书,电子邮件,标记文档,注释 ,档案和数据库。不仅文本,您还可以从各种文档格式中提取图像和元数据属性,包括PDF,XLS,XLSX,CSV,DOC,DOCX,PPT,PPTX,MPP,EML,MSG,OST,PST,ONE等。
其中,为了改善API的工作效率并简化开发人员的使用,从头开始对GroupDocs.Parser的架构进行了改进。此次更新将会提供GroupDocs.Parser for Java 19.11改进和简化的API。
本次更新增加了许多新功能,下面将会介绍本次更新的内容:
引入了Parser类以从任何受支持格式的文档中读取和提取数据。
所有数据类型的数据提取过程已统一。
产品架构从头进行了修改,以简化使用不同选项和类来处理数据的过程。
获取文档信息和预览生成的过程已简化。
迁移
由于产品已进行了重大更新,因此类,方法及其使用方式也已更改。但是,还尚未从包中删除旧版API,而是将其移至com.groupdocs.parser.legacy包中。升级到v19.11后,您只需在项目范围内将包从com.groupdocs.parser替换为com.groupdocs.parser.legacy。这就可以摆脱立即构建问题。 然后,您可逐步进行更新源代码,并使用新的公共API的类和方法。
下面将会介绍GroupDocs.Parser for Java v19.11中使用新旧API提取数据的简要比较。
文本
旧版:
// Create an extractor factory
ExtractorFactory factory = new ExtractorFactory();
// Create a text extractor
try (TextExtractor extractor = factory.createTextExtractor(filePath)) {
// Extract a text from the text extractor
String textLine = null;
do {
textLine = extractor.extractLine();
if (textLine != null) {
System.out.println(textLine);
}
}
while (textLine != null);
}新版:
// Create an instance of Parser class
try (Parser parser = new Parser(filePath)) {
// Extract a text to the reader
try (TextReader reader = parser.getText()) {
// Check if text extraction is supported
if (reader == null) {
System.out.println("Text extraction isn't supported.");
return;
}
// Extract a text from the reader
String textLine = null;
do {
textLine = reader.readLine();
if (textLine != null) {
System.out.println(textLine);
}
}
while (textLine != null);
}
}文本页
旧版:
// Create an extractor factory
ExtractorFactory factory = new ExtractorFactory();
// Create a text extractor
try (TextExtractor extractor = factory.createTextExtractor(filePath)) {
// Check if the extractor supports pagination
IPageTextExtractor pte = extractor instanceof IPageTextExtractor
? (IPageTextExtractor) extractor
: null;
if (pte != null) {
// Extract the first page
System.out.println(pte.extractPage(0));
}
}新版:
// Create an instance of Parser class
try (Parser parser = new Parser(filePath)) {
// Extract the first page text to the reader
try (TextReader reader = parser.getText(0)) {
// Check if text extraction is supported
if (reader != null) {
// Extract a text from the reader
System.out.println(reader.readToEnd());
}
}
}搜索
旧版:
// Create an extractor factory
ExtractorFactory factory = new ExtractorFactory();
// Create a text extractor
try (TextExtractor extractor = factory.createTextExtractor(filePath)) {
// Check if the extractor supports search
ISearchable se = extractor instanceof ISearchable
? (ISearchable) extractor
: null;
if (se != null) {
// Create a handler
ListSearchHandler handler = new ListSearchHandler();
// Search "keyword" in the document
se.search(new SearchOptions(null), handler, java.util.Arrays.asList(new String[]{"keyword"}));
// Print search results
for (SearchResult result : handler.getList()) {
System.out.println(String.format("at %d: %s", result.getIndex(), result.getFoundText()));
}
}
}新版:
// Create an instance of Parser class
try (Parser parser = new Parser(filePath)) {
// Search "keyword" in the document
Iterable list = parser.search("keyword");
// Check if search is supported
if (list == null) {
System.out.println("Search isn't supported.");
return;
}
// Print search results
for (SearchResult result : list) {
System.out.println(String.format("at %d: %s", result.getPosition(), result.getText()));
}
}文件类型检测
旧版:
// Detect and print file type System.out.println(CompositeMediaTypeDetector.DEFAULT.detect(filePath));
新版:
// Create an instance of Parser class
try (Parser parser = new Parser(filePath)) {
// Detect and print file type
System.out.println(parser.getDocumentInfo().getFileType());
}元数据
旧版:
// Create an extractor factory
ExtractorFactory factory = new ExtractorFactory();
// Create a metadata extractor
MetadataExtractor extractor = factory.createMetadataExtractor(filePath);
// Extract metadata
MetadataCollection metadata = extractor.extractMetadata(filePath);
// Print metadata
for (String key : metadata.getKeys()) {
String value = metadata.get_Item(key);
System.out.println(String.format("%s = %s", key, value));
}新版:
// Create an instance of Parser class
try (Parser parser = new Parser(filePath)) {
// Extract metadata
Iterable metadata = parser.getMetadata();
// Check if metadata extraction is supported
if (metadata == null) {
System.out.println("Metadata extraction isn't supported.");
return;
}
// Print metadata
for (MetadataItem item : metadata) {
System.out.println(String.format("%s = %s", item.getName(), item.getValue()));
}
}结构体
旧版:
// Create an extractor factory
ExtractorFactory factory = new ExtractorFactory();
// Create a text extractor
try (TextExtractor extractor = factory.createTextExtractor(filePath)) {
// Check if the extractor supports text structure extraction
IStructuredExtractor se = extractor instanceof IStructuredExtractor
? (IStructuredExtractor) extractor
: null;
if (se != null) {
// Create a handler
Handler handler = new Handler();
// Extract text structure
se.extractStructured(handler);
// Print hyperlinks
for (String link : handler.getLinks()) {
System.out.println(link);
}
}
}
// Handler for the hyperlink extraction
class Handler extends StructuredHandler {
private final java.util.List links;
public Handler() {
links = new java.util.ArrayList();
}
public java.util.List getLinks() {
return links;
}
// Override the method to catch hyperlinks
@Override
protected void onStartHyperlink(HyperlinkProperties properties) {
links.add(properties.getLink());
}
}新版:
// Create an instance of Parser class
try (Parser parser = new Parser(filePath)) {
// Extract text structure to the XML reader
Document document = parser.getStructure();
// Check if text structure extraction is supported
if (document == null) {
System.out.println("Text structure extraction isn't supported.");
return;
}
// Read XML document
readNode(document.getDocumentElement());
}
void readNode(Node node) {
NodeList nodes = node.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
Node n = nodes.item(i);
if (n.getNodeName().toLowerCase() == "hyperlink") {
Node a = n.getAttributes().getNamedItem("link");
if (a != null) {
System.out.println(a.getNodeValue());
}
}
if (n.hasChildNodes()) {
readNode(n);
}
}
}在线文档查看器GroupDocs.Viewer也已更新至v19.11,该版本修复许多小问题,感兴趣的朋友可以点击查看更新新闻。
如果您对想要购买正版授权GroupDocs.Parser,可以联系咨询相关问题。
关注慧聚IT微信公众号 ☟☟☟,了解产品的最新动态及最新资讯。

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@ke049m.cn




DevExpress WinForms控件v25.1日前已经全新发布,新版本的Ribbon、PDF Viewer(查看器)等组件功能全新升级等,欢迎下载最新版体验!
界面控件DevExpress WinForms v25.2将于今年年末左右更新,新版本将继续升级富文本编辑器控件功能等,欢迎关注我们及时获取最新消息~
PHP IDE——PhpStorm 发布了重大更新v2025.2,此版本官宣支持PHPUnit 12 、Junie 编码智能体重大升级等,欢迎下载最新版体验!
DevExpress WinForms控件v25.1日前已经全新发布,新版本全新数据编辑器、AI聊天控件功能增强等,欢迎下载最新版体验!
相关产品
构建可从多种文档格式中提取文本和元数据的.NET和Java应用程序。
半岛外围网上直营相关的文章 MORE
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@ke049m.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
半岛外围网上直营