aspose file tools*
The moose likes Other Open Source Projects and the fly likes insert  header and footer with  POI HWPF? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "insert  header and footer with  POI HWPF?" Watch "insert  header and footer with  POI HWPF?" New topic
Author

insert header and footer with POI HWPF?

juan sebastian sanchez
Greenhorn

Joined: Jul 14, 2009
Posts: 5
hi! I need your help!

how do you insert header and footer with POI HWPF? how can I replace a word in a World's document with POI wihtout a corruption file?

Thanks to somebody wich answer!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42932
    
  68
I don't think HWPF supports adding headers or footers directly, but if you base your document on an existing one (as demonstrated in http://faq.javaranch.com/java/CreateWordDocument) you may be able to use any header/footer that happens to exist in that document already.

Replacing text inside of a DOC document is discussed in this topic.
juan sebastian sanchez
Greenhorn

Joined: Jul 14, 2009
Posts: 5
Ulf Dittmer wrote:I don't think HWPF supports adding headers or footers directly, but if you base your document on an existing one (as demonstrated in http://faq.javaranch.com/java/CreateWordDocument) you may be able to use any header/footer that happens to exist in that document already.

Replacing text inside of a DOC document is discussed in this topic.


hi

when I replace words of different length the result file is corrupt

do you know why this happend?

thank for your help
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42932
    
  68
How are you doing the replacing? Post the relevant code here.
juan sebastian sanchez
Greenhorn

Joined: Jul 14, 2009
Posts: 5
Hi the code that I am used are this two classes:
1- http://test.javaranch.com/ulf/InsertText.java
2- http://test.javaranch.com/ulf/ParagraphText.java
I am replacing the method piece.usesUnicode() for piece.isUnicode()
I am using POI 3.2 and also test with POI 3.5 beta 6
I have another class for replace words, is this:






but with both forms I have problems because the file get corrupted when the length of the old word and new word are differents betweenword
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42932
    
  68
Post the code that uses those two classes for replacing text.
juan sebastian sanchez
Greenhorn

Joined: Jul 14, 2009
Posts: 5









Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42932
    
  68
Interesting. A doc file so changed is opened fine by both OpenOffice and Mellel (an OS X word processor), but not by Word itself. Might be something to ask on the POI mailing list about.
jetti madhu
Greenhorn

Joined: Feb 22, 2010
Posts: 7
Hi,
is there any one know how to get the images from .doc file using POI ?
asif aftab
Greenhorn

Joined: Aug 15, 2013
Posts: 3
http://stackoverflow.com/questions/26250065/adding-footer-to-ms-word-using-poi-api/26250188#26250188
Please check above link. In this post footer is added perfectly.
 
 
subject: insert header and footer with POI HWPF?