poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Schwarze <...@admadic.de>
Subject Re: [2] Need to set style of a character/paragraph using HWPF
Date Fri, 02 Mar 2007 15:45:39 GMT
Hi Turja,

At 12:16 02.03.2007, turjabarua wrote:
>Hi Rainer,
>             Thanks my problem is almost solved now. It is workign with
>existing document edit. 

I'm glad that I could help :-)

>But now the problem is whenever I want to create a
>new document and add a paragraph to that, it is throwing  
>java.io.FileNotFoundException: no such entry: "DocumentSummaryInformation"
>Error getting property set with name SummaryInformation n
>I read some previous threads and in one u have put a solution to add
> writeProperties(pfs);
>this line in write function of hwpfdocument....... but it is not

First question: How is it not working?

Second question: How do you create a new document?

>and add to that 
>if I want to copy one style from one document to the new one is there any
>way out??

You may try to take a StyleDescription from the source document, clone it
by creating a byte[] via calling toByteArray and creating a new
StyleDescription instance and add that to the destination document. (At
least that's the clone which seems to be implemented very quickly)

// in StyleDescription:
public StyleDescription createCopy() {
  byte [] data = this.toByteArray();
  StyleDescription sd = new StyleDescription(data, this._baseLength, 0, true);

// in StyleSheet add an addStyleDescription function ...
// (probably should return the index at which the new StyleDescription is

// in your main code
StyleDescription sd = srcDoc.getStyleSheet().getStyleDescription(idx);

You should read the Word spec and understand the _baseLength of the
StyleSheet/StyleDescription. Then test to see what this does in your Word
files. (The _baseLength could be different between two Word files and I
don't know immediately under which circumstances this could happen and what
would be the best solution for this case. As with every detail of the Word
format, one needs to check whether the spec is correct and matches your
actual files.)

Best wishes,

To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/

View raw message