Hi Team,
I am trying to insert few document pages (having contents like text, tables etc.) inside another document (docx format) to a specific location.
Actually I have one report (in docx format) which is getting generated from my application. Now I want to add few more contents in the form of new document pages to the existing document, before my application generates the final report.
Please see the code I have written:
public void callXYZr(HttpServletResponse response, ByteArrayRequestEntity byteArrayRequestEntity, ServiceContext scx ,String pType) throws IOException{
File tempWordTemplate =null;
try {
tempWordTemplate = File.createTempFile("newWordTemplate", ".docm");
// call to Database for fetching word template
WordTemplateDAO templateDao = new WordTemplateDAO(scx);
byte[] binData = templateDao.fetchWordDocument(pType);
OutputStream fs = new BufferedOutputStream( new FileOutputStream(tempWordTemplate));
fs.write(binData);
fs.flush();
fs.close();
WordprocessingMLPackage wmlPack = WordprocessingMLPackage.load(tempWordTemplate);
........... some more stuff.... goes here...
}
Now i need to put few more contents (word doc pages) inside a perticular location of the above generated docx file, let say in the middle of the document.
The new content is also another doc file whcih I have converted into binarydata format to put in the document. Is this approach right?
Thanks a lot in advance
How can I achieve this.. Please help me