This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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: 41123
    
  45
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 - my free Android networking tools app
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: 41123
    
  45
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: 41123
    
  45
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: 41123
    
  45
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
Adding Header/Footer to Word Document, created using HWPF/XWPF.
HWPF
Apache POI - HWPF writing a String
Bookmarks with HWPF
HWPF POI