tika-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael McCandless (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (TIKA-1181) RTFParser not keeping HTML font colors and underscore tags.
Date Mon, 07 Oct 2013 14:07:42 GMT

    [ https://issues.apache.org/jira/browse/TIKA-1181?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13788163#comment-13788163
] 

Michael McCandless commented on TIKA-1181:
------------------------------------------

The RTFParser currently only carries bold and italic styling through; I guess we could add
underline.

It doesn't try to preserve any colors.

Really the goal is (mostly?) text extraction, not precise formatting of the extracted text,
so I think colors/styling are somewhat low priority.  But I suppose underling/colors can convey
information about how important that text was, and so could be useful to stages (like indexing
with Lucene) after text extraction.


> RTFParser not keeping HTML font colors and underscore tags.
> -----------------------------------------------------------
>
>                 Key: TIKA-1181
>                 URL: https://issues.apache.org/jira/browse/TIKA-1181
>             Project: Tika
>          Issue Type: Bug
>          Components: parser
>    Affects Versions: 1.4
>         Environment: Windows server 2008
>            Reporter: Leo
>              Labels: RTFParser
>
> Hi,
> I'm having problems with this code. It does not put the font colors and underscores "<u></u>"
tags in the HTML from the RTF string. Is there anything I can do to put them there? 
> Code:
> InputStream in = new ByteArrayInputStream(rtfString.getBytes("UTF-8"));  
> 		   
> org.apache.tika.parser.rtf.RTFParser parser = new org.apache.tika.parser.rtf.RTFParser();
> 		   		   
> Metadata metadata = new Metadata();
> StringWriter sw = new StringWriter();
> SAXTransformerFactory factory = (SAXTransformerFactory)
> 		             SAXTransformerFactory.newInstance();
> TransformerHandler handler = factory.newTransformerHandler();
> 		    handler.getTransformer().setOutputProperty(OutputKeys.METHOD, "xml");
> 		    handler.getTransformer().setOutputProperty(OutputKeys.INDENT, "no");
> handler.setResult(new StreamResult(sw));
> parser.parse(in, handler, metadata, new ParseContext());
> String xhtml = sw.toString();
> 		    
> xhtml = xhtml.replaceAll("\r\n", "<br>\r\n");
> Thanks for looking at it.
> Leo



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Mime
View raw message