What I am wanting to do is take in a word doc/docx template which already has pre-designed headers and footers and replace certain words with words applicable with that document generated from what a user has input and has been saved through MySQL. I already have a program that works to get the user input and saves to the MySQL. However, I'm a little confused at how the word manipulation would work into this. I found docx4j and a tutorial that shows what I am looking for here and have found on another question on this site example code here. As I'm a beginner in using this, the things I'm confused on are:
- I understand JAXB is used for converting to and from XML. Why is this relevant in a situation like this? Or if it's not, in what case would it be?
I am seeing two versions of loading:
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new java.io.File("P:\\Engineering\\Projects\\Naming\\EX_TEMP.docx"));
........ and the second example:
private WordprocessingMLPackage getTemplate(String name) throws Docx4JException, FileNotFoundException {
WordprocessingMLPackage template = WordprocessingMLPackage.load(new FileInputStream(new File(name)));
return template;
}
(where would you put the file directory on the second code, or how can you specify the file you want to load?)
- what does hyperlinkresolver do and why is it necessary? (second link)
- what is applying binding in this situation? (second link)
- what is the content accessor? (first link)
- am I going about this the right way, or is there an easier/better way of doing this?
I am using Eclipse with Java on a Windows 7 if that helps. I would appreciate any help, thanks! Also if anyone has any examples with good comments or explanations, that would be helpful!