Hi, I am working for Apache POI, HWPF Documents Used to concatenate 2 word documents.
I am able to concatenate 2 word documents and display result in 3rd document. But, as i am concatenating, the font type, size, bold are not coming in result document
When i read one word document, and update result document, everything is coming fine. ie result document has all font size, bold format is correct
But, try to open existing word document in append mode and updating other documents, the result document is resulting only with first document, not updating 2nd document.
FileInputStream fileInputStream = new FileInputStream(new File(Infilename)); BufferedInputStream buffInputStream = new BufferedInputStream(fileInputStream); HWPFDocument document = new HWPFDocument(buffInputStream); range = new Range(0,document.characterLength(),document); range.insertBefore(pos+". ");
File outfile = new File(Outfilename); FileOutputStream fileOutputStream =new FileOutputStream(outfile,true); BufferedOutputStream buffOutputStream = new BufferedOutputStream(fileOutputStream); document.write(buffOutputStream);
i am adding some text to the range of new document and writing the new document. I am opening the FileOutputStream in append mode, ie true.. so, i think it will append the existing file.
"Lalitha Devi G" please check your private messages for an important administrative matter. You can see them by clicking the My Private Messages link above.
DOC is a structure document format. You can't append one document to another by writing two DOC file streams into a single file. You'll need to open the other file as an HWPF document as well, and then insert the text range of the first file into it.
First of all, please change your screen name according to the JavaRanch naming policy - a first name and a last name are required.
You need to open both files as HWPF documents, and then get a Range object of the document you want to append. Then you can insert that behind the Range object of the document you want to append to. You already have most of that code in the snippet you posted before.
"gld", please read the policy on screen names: http://www.javaranch.com/name.jsp A valid screen name is not optional - accounts without it are generally closed. To avoid this, please fix yours before your next post.
I'm not sure how exactly to accomplish appending documents, but I'm sure it has something to with what's mentioned in "Changing text" in http://poi.apache.org/hwpf/quick-guide.html
An empty document can be created by "new HWPFDocument(new POIFSFileSystem())". How are you trying to append the files? Post the code, and we may be able to help.
The line of code you posted doesn't do anything with DocumentSummaryInformation; where is that error message coming from? If you post code, seeing more than a single line would be helpful.