• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Read the .doc file

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could any one give some sample code to read the .doc (MS word ) file with the font style, family and size usi ng java?.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Apache POI library can do this, in particular its HWPF module. From an HWPFDocument object you can get CharacterRun objects that encapsulate the text and its formatting. Something like:
 
Megan James
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply sir. I tried to downloaded the jar file , but i got only the source code its also not compiled properly, It has some file as missing in that. could you provide the url for downloaded the jar file of open source or how can i get the complete source code.could you help me to proceed future.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On the POI site, follow the "Download" link. You may need to click through "release" and "bin" directories to get to the correct file. It should be called poi-bin-3.2-FINAL-20081019.zip, and it contains the poi-scratchpad-3.2.jar and poi-3.2.jar files that you need to add to your classpath.

What do you mean by "it's not compiled properly" - do you mean the code I posted? You need to add import statements, and of course you must have the POI jar files in your classpath.
 
Megan James
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your comments. I got the jar file and set class path.

When running the above code it shows the following error . Kindly help me to proceed future.

org.apache.poi.hpsf.IllegalPropertySetDataException: The property set claims to have a size of 16 bytes. However, it exceeds 16 bytes.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which statement is causing this exception? Does Word have any problems with this file?
 
Megan James
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The above problem was caused because of some problem in my word format. I solved it. Thanks for your Help.
 
A sonic boom would certainly ruin a giant souffle. But this tiny ad would protect it:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic