You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Andrei Khveras <an...@gmail.com> on 2012/01/10 16:51:20 UTC
Tab symbols parsing in WORD document issue: org.apache.poi.hwpf.extractor.WordExtractor
He everybody!
I'm trying to use the class org.apache.poi.hwpf.extractor.WordExtractor,
what
I downloaded as a part of Apache POI <http://poi.apache.org/download.html>.
*Could somebody, please*, kindly help me to resolve this little issue. My
goal is to get
MS Word file contents as one single String, containing all control
characters. I need it
for further (hand-made!) splitting text into paragraphs, words, etc. When I
pass to MY PROGRAM <https://gist.github.com/1589465>
sequentially both TestDoc1.doc and TestDoc2.doc I got the same result,
although
TestDoc2.doc has one additional tab
<http://en.wikipedia.org/wiki/Tab_key>before the text.
Could you please advice me how to get all contents of .doc file with taking
into account
all control symbols?
Looking forward to your reply. Thanks in advance.
--
*Best Regards
*
*
Andrei
Your java programming colleague
*
Re: Tab symbols parsing in WORD document issue: org.apache.poi.hwpf.extractor.WordExtractor
Posted by Andrei Khveras <an...@gmail.com>.
Hi. Thank you for prompt reply. Unfortunately, getParagraph() function
fetches not paragraphs, but single lines, that ends with
newline<http://en.wikipedia.org/wiki/Newline>symbols. I consider a
paragraph as any text with preceding
newline <http://en.wikipedia.org/wiki/Newline> or
pagebreak<http://en.wikipedia.org/wiki/Page_break>and
TAB <http://en.wikipedia.org/wiki/Tab_key> symbols. Anyhow, allthought I'm
not sure I can read complicated professional code, I will try to analyse it
and to do my best of understanding it and finding the ways of resolving the
issue above.
On Tue, Jan 10, 2012 at 6:56 PM, Nick Burch <ni...@alfresco.com> wrote:
> On Tue, 10 Jan 2012, Andrei Khveras wrote:
>
>> I'm trying to use the class org.apache.poi.hwpf.extractor.**WordExtractor,
>> what I downloaded as a part of Apache POI <http://poi.apache.org/**
>> download.html <http://poi.apache.org/download.html>>.
>>
>> *Could somebody, please*, kindly help me to resolve this little issue. My
>> goal is to get MS Word file contents as one single String, containing all
>> control characters. I need it for further (hand-made!) splitting text into
>> paragraphs, words, etc.
>>
>
> Why not fetch the paragraphs directly then? That'd give you full control
> over which bit of text is in which paragraph, and will let you decide if
> you want to display or hide control characters etc
>
> I'd suggest you look at the code for WordExtractor to get an idea of how
> to go about doing it, then do your own version that implements your
> required logic
>
> Nick
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.**org<us...@poi.apache.org>
> For additional commands, e-mail: user-help@poi.apache.org
>
>
--
*С уважением*
*Андрей
*
* 229-507-907 <http://wwp.icq.com/scripts/contact.dll?msgto=229507907>*
*Skype: tenety
BOOKRIVER.RU <http://bookriver.ru>
*
Re: Tab symbols parsing in WORD document issue: org.apache.poi.hwpf.extractor.WordExtractor
Posted by Sergey Vladimirov <vl...@gmail.com>.
Andrey,
You can ontain full document text (but without included OLE files!)
using TextPieceTable.getText(). It will return text only with all
included special chars (no filtering).
Sergey
On Tue, Jan 10, 2012 at 11:20 PM, Andrei Khveras
<an...@gmail.com> wrote:
> Thank you. I'll try look the source code or look for some other solution.
>
> On Tue, Jan 10, 2012 at 9:47 PM, Nick Burch <ni...@alfresco.com> wrote:
>
>> On Tue, 10 Jan 2012, Andrei Khveras wrote:
>>
>>> Hi. Thank you for prompt reply. Unfortunately, getParagraph() function
>>> fetches not paragraphs, but single lines, that ends with
>>> newline<http://en.wikipedia.**org/wiki/Newline<http://en.wikipedia.org/wiki/Newline>
>>> >symbols.
>>>
>>
>> It'll only do that if someone has done something really really odd with
>> their file... HWPF will give you back what's actually in your file, which
>> normally means paragraphs as you expect them. It sounds like in your case
>> though, someone has created one paragraph per line, and messed about with
>> the paragraph spacing! Not a lot we can do to help in the case of such odd
>> files - HWPF just gives you what the file contains
>>
>>
>> Nick
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.**org<us...@poi.apache.org>
>> For additional commands, e-mail: user-help@poi.apache.org
>>
> *
> *
--
Sergey Vladimirov
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: Tab symbols parsing in WORD document issue: org.apache.poi.hwpf.extractor.WordExtractor
Posted by Andrei Khveras <an...@gmail.com>.
Thank you. I'll try look the source code or look for some other solution.
On Tue, Jan 10, 2012 at 9:47 PM, Nick Burch <ni...@alfresco.com> wrote:
> On Tue, 10 Jan 2012, Andrei Khveras wrote:
>
>> Hi. Thank you for prompt reply. Unfortunately, getParagraph() function
>> fetches not paragraphs, but single lines, that ends with
>> newline<http://en.wikipedia.**org/wiki/Newline<http://en.wikipedia.org/wiki/Newline>
>> >symbols.
>>
>
> It'll only do that if someone has done something really really odd with
> their file... HWPF will give you back what's actually in your file, which
> normally means paragraphs as you expect them. It sounds like in your case
> though, someone has created one paragraph per line, and messed about with
> the paragraph spacing! Not a lot we can do to help in the case of such odd
> files - HWPF just gives you what the file contains
>
>
> Nick
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.**org<us...@poi.apache.org>
> For additional commands, e-mail: user-help@poi.apache.org
>
*
*
Re: Tab symbols parsing in WORD document issue:
org.apache.poi.hwpf.extractor.WordExtractor
Posted by Nick Burch <ni...@alfresco.com>.
On Tue, 10 Jan 2012, Andrei Khveras wrote:
> Hi. Thank you for prompt reply. Unfortunately, getParagraph() function
> fetches not paragraphs, but single lines, that ends with
> newline<http://en.wikipedia.org/wiki/Newline>symbols.
It'll only do that if someone has done something really really odd with
their file... HWPF will give you back what's actually in your file, which
normally means paragraphs as you expect them. It sounds like in your case
though, someone has created one paragraph per line, and messed about with
the paragraph spacing! Not a lot we can do to help in the case of such odd
files - HWPF just gives you what the file contains
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: Tab symbols parsing in WORD document issue: org.apache.poi.hwpf.extractor.WordExtractor
Posted by Andrei Khveras <an...@gmail.com>.
Hi. Thank you for prompt reply. Unfortunately, getParagraph() function
fetches not paragraphs, but single lines, that ends with
newline<http://en.wikipedia.org/wiki/Newline>symbols. I consider a
paragraph as any text with preceding
newline <http://en.wikipedia.org/wiki/Newline> or
pagebreak<http://en.wikipedia.org/wiki/Page_break>symbols. Anyhow,
allthought I'm not sure I can read complicated
professional code, I will try to analyse it and to do my best of
understanding it and finding the ways of resolving the issue above.
On Tue, Jan 10, 2012 at 6:56 PM, Nick Burch <ni...@alfresco.com> wrote:
> On Tue, 10 Jan 2012, Andrei Khveras wrote:
>
>> I'm trying to use the class org.apache.poi.hwpf.extractor.**WordExtractor,
>> what I downloaded as a part of Apache POI <http://poi.apache.org/**
>> download.html <http://poi.apache.org/download.html>>.
>>
>> *Could somebody, please*, kindly help me to resolve this little issue. My
>> goal is to get MS Word file contents as one single String, containing all
>> control characters. I need it for further (hand-made!) splitting text into
>> paragraphs, words, etc.
>>
>
> Why not fetch the paragraphs directly then? That'd give you full control
> over which bit of text is in which paragraph, and will let you decide if
> you want to display or hide control characters etc
>
> I'd suggest you look at the code for WordExtractor to get an idea of how
> to go about doing it, then do your own version that implements your
> required logic
>
> Nick
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.**org<us...@poi.apache.org>
> For additional commands, e-mail: user-help@poi.apache.org
>
>
--
*С уважением*
*Андрей
*
* 229-507-907 <http://wwp.icq.com/scripts/contact.dll?msgto=229507907>*
*Skype: tenety
BOOKRIVER.RU <http://bookriver.ru>
*
Re: Tab symbols parsing in WORD document issue:
org.apache.poi.hwpf.extractor.WordExtractor
Posted by Nick Burch <ni...@alfresco.com>.
On Tue, 10 Jan 2012, Andrei Khveras wrote:
> I'm trying to use the class org.apache.poi.hwpf.extractor.WordExtractor,
> what I downloaded as a part of Apache POI
> <http://poi.apache.org/download.html>.
>
> *Could somebody, please*, kindly help me to resolve this little issue.
> My goal is to get MS Word file contents as one single String, containing
> all control characters. I need it for further (hand-made!) splitting
> text into paragraphs, words, etc.
Why not fetch the paragraphs directly then? That'd give you full control
over which bit of text is in which paragraph, and will let you decide if
you want to display or hide control characters etc
I'd suggest you look at the code for WordExtractor to get an idea of how
to go about doing it, then do your own version that implements your
required logic
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org