You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Srinivas <sr...@yahoo.com> on 2004/10/09 09:53:34 UTC

Count the number of Lines and words in the Word Document.......

Hi Guys,
 
              I am using the POI in my application, i am able to insert the data into word 
document and read the data from the word document .
 
but my aim is how to find the number of lines in the documement and count the number of words in 
that word document ..
 
 
Is it possible to find out the lines and words in that word documents ....
Please help me...
 
Thanks for Advance..
 
Srinivas


		
---------------------------------
Do you Yahoo!?
vote.yahoo.com - Register online to vote today!

RE: Count the number of Lines and words in the Word Document.......

Posted by Michael Zalewski <za...@optonline.net>.
Counting the number of lines is gonna be tough. You can look at the HPSF
properties, but the property may not be present, and may not be correct if
even if it is present. Without relying on the value stored in document
properties, you will have to compute line sizes yourself. It means you need
to compute where each line of the document will wrap, by taking into account
the size and spacing of each string of characters. You need access to
FontMetrics, which is largely unavailable from Java.

Did you know that the number of lines could depend on which printer was last
selected? I think Word wraps lines according to the device context of the
current printer. So a printer with a different resolution may cause the
lines to wrap slightly differently.

I have seen this effect on newsletters and other 'desk top publishing
documents' done in Word. If you mail the newsletter from one person to
another, and the recipient does not have the same printer driver, the
recipient may very well find that the lines in the document wrap
differently, or even in extreme cases, that the document has a different
number of pages.

-----Original Message-----
From: Rainer Klute [mailto:klute@rainer-klute.de]
Sent: Saturday, October 09, 2004 4:46 AM
To: POI Users List
Subject: Re: Count the number of Lines and words in the Word Document.......

Am Sa, 2004-10-09 um 09.53 schrieb Srinivas:
>               I am using the POI in my application, i am able to insert
the data into word
> document and read the data from the word document .
>
> but my aim is how to find the number of lines in the documement and count
the number of words in
> that word document ..
>
>
> Is it possible to find out the lines and words in that word documents ....
> Please help me...

If you don't want to count words and lines yourself but instead rely on
the document's properties, you should HPSF to access the latter.

Best regards
Rainer Klute

                           Rainer Klute IT-Consulting GmbH
  Dipl.-Inform.
  Rainer Klute             E-Mail:  klute@rainer-klute.de
  Körner Grund 24          Telefon: +49 172 2324824
D-44143 Dortmund           Telefax: +49 231 5349423


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org


Re: Count the number of Lines and words in the Word Document.......

Posted by Rainer Klute <kl...@rainer-klute.de>.
Am Sa, 2004-10-09 um 09.53 schrieb Srinivas:
>               I am using the POI in my application, i am able to insert the data into word 
> document and read the data from the word document .
>  
> but my aim is how to find the number of lines in the documement and count the number of words in 
> that word document ..
>  
> 
> Is it possible to find out the lines and words in that word documents ....
> Please help me...

If you don't want to count words and lines yourself but instead rely on
the document's properties, you should HPSF to access the latter.
 
Best regards
Rainer Klute

                           Rainer Klute IT-Consulting GmbH
  Dipl.-Inform.
  Rainer Klute             E-Mail:  klute@rainer-klute.de
  Körner Grund 24          Telefon: +49 172 2324824
D-44143 Dortmund           Telefax: +49 231 5349423


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org