This week's book giveaway is in the General Computing forum.
We're giving away four copies of Emmy in the Key of Code and have Aimee Lucido on-line!
See this thread for details.
Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

insert header and footer with POI HWPF?

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you doing the replacing? Post the relevant code here.
 
juan sebastian sanchez
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the code that uses those two classes for replacing text.
 
juan sebastian sanchez
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator









 
Ulf Dittmer
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
is there any one know how to get the images from .doc file using POI ?
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
You didn't tell me he was so big. Unlike this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!