poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Zalewski <zalew...@optonline.net>
Subject RE: Count the number of Lines and words in the Word Document.......
Date Sat, 09 Oct 2004 20:08:04 GMT
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


Mime
View raw message