473,698 Members | 2,833 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert document file into rtf file

9 New Member
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 4177
r035198x
13,262 MVP
Why are you using jacob.jar for that? Use Apache's poi.
Aug 13 '08 #2
nanaveraa
9 New Member
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 Recognized Expert MVP
Who or what formatted your soure code? A firecracker? It is completely unreadable.

kind regards,

Jos
Aug 13 '08 #4
nanaveraa
9 New Member
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
manishvrm
1 New Member
hi sir....


i need to convert .doc file to .html file in java..plz help sir..
Oct 20 '08 #6
r035198x
13,262 MVP
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
8674
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 convert this to an HTML document and when the user looks at the source they see HTML instead of XML (which is the current source and extention). I want to accomplish this on the client side, I tried using the following in an HTML file but again the...
0
17976
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 wich iTextSharp.text.Image.getInstance(...) signature I am using : - using code 1 below, the conversion is fast enough but the resulting PDF file is too big (1 817ko sample Tiff file is converted in less than 30 seconds to a 2 764ko PDF file) -...
2
3408
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 file, convert the FileStream into a string using Unicode encoding, then do a replace, then convert the string back to a byte using Unicode encoding which i then Response.WriteBinary(bytes) to the browser. This works fine although the actual...
1
3852
by: Ashutosh | last post by:
How can i convert Word file to txt file in ASP.NET using CSharp?
3
1632
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. The conversion need to be done in coding as a web service using ASP/ASP.Net 2) How to import pulic classes into an ASP file (in java we use, import) Thanks
7
15034
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 convert the displayed csv file in the textbox to Xml and use the first line of the csv file as tags. I know there will be different ways of doing this but i would like to keep it simple because i am new to programming and the Visual Basic.Net...
4
4469
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 server. Does anyone have any examples on how to do this ?? I dont really understand how to get from HTML string to HTML document. I can probably work out how to save this. do i create an html object ??
3
3154
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 somebody, please, help me out? I am on this for days. My code is as follows:
6
8648
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 link for the end users to download the word file? FYI, the database records are obtained by end users submitting the forms themselve and i saved it in my db... Thanx.
0
1861
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 path of any file that user wants. After that i need to show the preview of that file. If there is any way to convert any document in xps file then i can convert it in tiff file format. So please if you have any idea to convert document in xps format...
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8611
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8904
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8876
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6531
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.