473,405 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Convert document file into rtf file

Hai,
i am tried to convert a .doc file into .rtf format file using jacob jar.i am written a code but its gives some error. In below i given that programs and error.please give me the solution to solve the problem.
Expand|Select|Wrap|Line Numbers
  1. import java.io.*;
  2.   import java.io.File;  
  3. import com.jacob.com.*;
  4.   import com.jacob.activeX.*;   
  5.   public class convertDoc2Rtf {       
  6.   private final static String DOC_FORMAT = ".doc";  
  7.     private final static String RTF_FORMAT = ".rtf";     
  8.        public convertDoc2Rtf(){} 
  9.         public static void main(String[] args)throws IOException {           try{            
  10.   String fileName = "D:/test.doc";              if(fileName.lastIndexOf(DOC_FORMAT) == fileName.length() - DOC_FORMAT.length())
  11.  {              
  12. String strDoc = new File(fileName).getAbsolutePath();  String strRtf = new String(strDoc.substring(0, strDoc.lastIndexOf(DOC_FORMAT)) + RTF_FORMAT);      
  13.                 ActiveXComponent oWord = new ActiveXComponent("Word.Application");                      oWord.setProperty("Visible", new Variant(false));                                    Dispatch oDocuments = oWord.getProperty("Documents").toDispatch();          Dispatch oDocument = Dispatch.call(oDocuments, "Open", strDoc).toDispatch();        
  14.   Dispatch oWordBasic = (Dispatch) Dispatch.call(oWord, "WordBasic").getDispatch();          
  15. Dispatch.call(oWordBasic, "FileSaveAs", strRtf);          Dispatch.call(oDocument, "Close", new Variant(false));                            oWord.invoke("Quit", new Variant[0]);                  System.out.println(strRtf);              }         
  16.  }catch(Exception e)
  17. {System.out.println("Exception "+e);}         // convertDoc2Rtf converter = new convertDoc2Rtf();         }    
  18.  }
Error is
Expand|Select|Wrap|Line Numbers
  1. Exception in thread "main" java.lang.UnsatisfiedLinkError: createInstanceNative          at com.jacob.com.Dispatch.createInstanceNative(Native Method)          at com.jacob.com.Dispatch.<init>(Dispatch.java:161)          at com.jacob.activeX.ActiveXComponent.<init>(ActiveXComponent.java:54)          at projectbytes.convertDoc2Rtf.main(convertDoc2Rtf.java:24)
  2. Java Result: 1
Aug 13 '08 #1
6 4166
r035198x
13,262 8TB
Why are you using jacob.jar for that? Use Apache's poi.
Aug 13 '08 #2
Why are you using jacob.jar for that? Use Apache's poi.
Thankyou for your reply

In poi we are only read the file and i don't know how to convert the file.so pls give me the idea to do this.
Aug 13 '08 #3
JosAH
11,448 Expert 8TB
Who or what formatted your soure code? A firecracker? It is completely unreadable.

kind regards,

Jos
Aug 13 '08 #4
Who or what formatted your soure code? A firecracker? It is completely unreadable.

kind regards,

Jos

It is java code using jocob jar. It downloaded on site.

Thank U 4 your response,
Nan Averaa
Aug 26 '08 #5
hi sir....


i need to convert .doc file to .html file in java..plz help sir..
Oct 20 '08 #6
r035198x
13,262 8TB
hi sir....


i need to convert .doc file to .html file in java..plz help sir..
What have you done about it so far?
Oct 20 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Closer | last post by:
I am new to XML and XSL, could someone please help? I have my XML and XSL files and can view the XML file with the stylesheet in my browser. Everything is fine. What I want to do is to...
0
by: Nicolas Guilhot | last post by:
Hi all ! I have a multi-page Tiff image file that I want to convert to PDF. To do so I am using iText library. The conversion is working, but the code execution is very different according to...
2
by: Christopher Beltran | last post by:
I am currently trying to replace certain strings, not single characters, with other strings inside a word document which is then sent to a browser as a binary file. Right now, I read in the word...
1
by: Ashutosh | last post by:
How can i convert Word file to txt file in ASP.NET using CSharp?
3
by: Kishore | last post by:
1) Is there a way to convert a file (MPP format) into an XML document in ASP. Is there any relation with XMLSerializer class with this. Can we use this class to convert a file into an XML Document....
7
by: Ish2000 | last post by:
Hello, I've a simple windows application and i want to be able to convert a csv file to xml. So far, i can browse for the csv file from the file structure and display in a textbox. I want to...
4
by: csgraham74 | last post by:
Hi, Ive posted on this previously but had no response. Basically i need to build some html using a rich text editor. Then i want to actually create an html document from this and save it to my...
3
by: shapper | last post by:
Hello, Could someone tell me how to convert a XML file into another XML file using a XSL file with a parameter? I created the code to do it, and it seems ok, but it is not working. Could...
6
by: Justin | last post by:
Hi all, i need some help over here... i found the solution to export file from mysql db into *.csv. but is there anyway to convert the contents into *.doc and save in my webserver and providing a...
0
by: ashz | last post by:
Hi All, I want to convert any document to tiff file format. Is it possible using dot net. Actually i have a simple button in my form that open a OpenFileDialog control. Using this i get the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.