Hi, I'm trying to make an aplicarion that modifys a word document (plantilla.doc). I'm changing it byte to byte, but then I need cange its length. Is there an easyer method to do that
If your question is about modifying the file size, for example, writing to the end of a file and making it bigger, this is possible with java.io.RandomAccessFile class, which can be used to change the bytes within the existing file contents too (i.e within existing EOF).
But if you want to insert bytes, somewhere in between the file, you might have to use buffers to move existing contents, before writing the bytes to be inserted in the appropriate location.
Anyway, when it comes to editing word documents programmatically in .NET, please have a look at this link for the recommended approach.
It's not Word, but here is an article I have written about Excel and J# automation. I hope this will give you an idea what it's all about.
The performance is extremely bad, and you can't use it on a server. The only solution to the performance issue is to use a third part component or by manipulating the disk file. Using XML you have a Microsoft documented way of doing it.
Please use the taskmanager to see that the Word process gets terminated after you are done with the automation. If you forget to close word in your app, you could end up with tens or hundreds of Word processes in memory. Word could be running even if you can't see it on the desktop or on the start-bar.
I took the time to learn the Word XML file model. This will outperform any automation by far, and it can run on a server.
If you are using Word 2003, it is more easier to save the doc as a Word XML file. That way you have 100% control over the word doc. You can find the Word XML docs here:
microsoft word documents
Rulatir
Hi
If your question is about modifying the file size, for example, writing to the end of a file and making it bigger, this is possible with java.io.RandomAccessFile class, which can be used to change the bytes within the existing file contents too (i.e within existing EOF).
But if you want to insert bytes, somewhere in between the file, you might have to use buffers to move existing contents, before writing the bytes to be inserted in the appropriate location.
Anyway, when it comes to editing word documents programmatically in .NET, please have a look at this link for the recommended approach.
http://msdn.microsoft.com/library/default.asp url=/library/en-us/odc_vsto2003_ta/html/WordObject.asp
Thanks
Ashwin Raja
Gabri
The performance is extremely bad, and you can't use it on a server. The only solution to the performance issue is to use a third part component or by manipulating the disk file. Using XML you have a Microsoft documented way of doing it.
http://www.codeproject.com/dotnet/JExcel.asp
Please use the taskmanager to see that the Word process gets terminated after you are done with the automation. If you forget to close word in your app, you could end up with tens or hundreds of Word processes in memory. Word could be running even if you can't see it on the desktop or on the start-bar.
I took the time to learn the Word XML file model. This will outperform any automation by far, and it can run on a server.
Tobin
erato
If you are using Word 2003, it is more easier to save the doc as a Word XML file. That way you have 100% control over the word doc. You can find the Word XML docs here:
http://msdn.microsoft.com/office/
http://msdn.microsoft.com/office/understanding/word/default.aspx
ReubenEmmanuel