*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
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: 39576
    
  27
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.


Ping & DNS - updated with new look and Ping home screen widget
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: 39576
    
  27
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: 39576
    
  27
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: 39576
    
  27
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 ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: insert header and footer with POI HWPF?
 
Similar Threads
HWPF
HWPF POI
Apache POI - HWPF writing a String
Bookmarks with HWPF
Adding Header/Footer to Word Document, created using HWPF/XWPF.