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
>working..... 

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)

<code>
// 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
stored)

// in your main code
StyleDescription sd = srcDoc.getStyleSheet().getStyleDescription(idx);
dstDoc.getStyleSheet().addStyleDescription(sd.createCopy());
</code>

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,
Rainer


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

Reply via email to