I want to read the formated text as a html text like(<html><b>boldvalue<b><img src"link" ></html>) also i want to get the image using the image tag link. I'm using poi does poi have any option to get data like this in html format?
Asked
Active
Viewed 1,371 times
0
-
1http://stackoverflow.com/questions/7868713/convert-word-to-html-with-apache-poi - duplicate – Jayan Jun 13 '13 at 05:43
-
than how can i get image from the image tag – user25226 Jun 13 '13 at 06:00
-
The image tags are comes with comment line also css are comes in a class but i want the css with in the tag like
. how to get this
– user25226 Jun 13 '13 at 08:10
1 Answers
1
try this
HWPFDocumentCore wordDocument = WordToHtmlUtils.loadDoc(new FileInputStream("D:\\temp\\seo\\1.doc"));
WordToHtmlConverter wordToHtmlConverter = new WordToHtmlConverter(
DocumentBuilderFactory.newInstance().newDocumentBuilder()
.newDocument());
wordToHtmlConverter.processDocument(wordDocument);
Document htmlDocument = wordToHtmlConverter.getDocument();
ByteArrayOutputStream out = new ByteArrayOutputStream();
DOMSource domSource = new DOMSource(htmlDocument);
StreamResult streamResult = new StreamResult(out);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
serializer.setOutputProperty(OutputKeys.INDENT, "yes");
serializer.setOutputProperty(OutputKeys.METHOD, "html");
serializer.transform(domSource, streamResult);
out.close();
String result = new String(out.toByteArray());
System.out.println(result);

shreyansh jogi
- 2,082
- 12
- 20
-
2
-
It return html values but the style are comes as class instead of how can i get the style with in tag like this(
) . – user25226 Jun 13 '13 at 07:51
-