Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: How to convert .gif text into .txt or .doc file in java

  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to convert .gif text into .txt or .doc file in java

    i want to convert text which is written in .gif file into .txt or .doc formate.
    although i have converted .gif into .pdf but i want into .txt or .doc.
    although m able to convert it from .gif to .pdf but i want to convert it from .gif to .txt or .doc
    below is the code for .gif to .pdf
    import java.io.FileOutputStream;

    //com.lowagie... old version
    //com.itextpdf... recent version
    import com.itextpdf.text.DocListener;
    import com.itextpdf.text.Document;
    import com.itextpdf.text.pdf.PdfWriter;
    import com.itextpdf.text.pdf.codec.TiffWriter;
    import com.itextpdf.text.Image;


    public class ImageToPDF {
    public static void main(String []args) {
    Document document = new Document();
    String input = "E:/Softwares/jars/error.png"; // .gif and .jpg are ok too!
    String output = "E:/Softwares/jars/capture.pdf";
    try {
    FileOutputStream fos = new FileOutputStream(output);
    PdfWriter writer = PdfWriter.getInstance(document, fos);
    // TiffWriter writer=TiffWriter.getInstance(document,fos);
    ((DocListener) writer).open();
    document.open();
    document.add(Image.getInstance(input));
    document.close();
    writer.close();
    System.out.println("in try");
    }
    catch (Exception e) {
    e.printStackTrace();
    }
    }
    }


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: How to convert .gif text into .txt or .doc file in java

    Welcome m.vinay09

    Please use code tags when posting code to the forum. Instructions can be found on the Announcements page
    What do you seem to be stuck on in creating your .txt file from the .gif?
    Can you read the .gif? Can you save to a .txt?
    Please explain what you are having trouble with.

  3. #3
    Junior Member
    Join Date
    May 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to convert .gif text into .txt or .doc file in java

    [QUOTE=jps;114554]Welcome m.vinay09

    Thanks for informing

    i want to convert **text which is written in .gif file into .txt or .doc format**.
    although i have converted .gif into .pdf but i want into .txt or .doc.
    please reply...

     
    import java.io.FileOutputStream;
     
    //com.lowagie...   old version
    //com.itextpdf...  recent version
    import com.itextpdf.text.DocListener;
    import com.itextpdf.text.Document;
    import com.itextpdf.text.pdf.PdfWriter;
    import com.itextpdf.text.pdf.codec.TiffWriter;
    import com.itextpdf.text.Image;
     
     
    public class ImageToPDF {
    public static void main(String []args) {
      Document document = new Document();
      String input = "E:/Softwares/jars/error.png"; // .gif and .jpg are ok too!
      String output = "E:/Softwares/jars/capture.pdf";
      try {
        FileOutputStream fos = new FileOutputStream(output);
       PdfWriter writer = PdfWriter.getInstance(document, fos);
       // TiffWriter writer=TiffWriter.getInstance(document,fos);
        ((DocListener) writer).open();
        document.open();
        document.add(Image.getInstance(input));
        document.close();
        writer.close();
        System.out.println("in try");
      }
      catch (Exception e) {
        e.printStackTrace();
      }
    }
    }

  4. #4
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: How to convert .gif text into .txt or .doc file in java

    There are many steps involved with your problem and I do not understand where you are stuck.
    Please explain what you are having problems with

  5. #5
    Junior Member
    Join Date
    May 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to convert .gif text into .txt or .doc file in java

    Hi,


    Actually i have .gif file in that file there are text written as suppose we have scan an book article and save it as .gif.
    Now i have to convert that gif file into .txt or .doc file.
    We can convert .gif to .pdf.
    But i m unable to convert it as .txt through java program.

    Kindly reply the solution.

  6. #6
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: How to convert .gif text into .txt or .doc file in java

    Quote Originally Posted by m.vinay09@gmail.com View Post
    suppose we have scan an book article and save it as .gif.
    Now i have to convert that gif file into .txt or .doc file.
    ...
    Kindly reply the solution.
    I understand what you wish to do. We do not write solutions, we offer advice to people writing their own solution when they have a question.
    If you have a question post it and hopefully someone will try to answer it

Similar Threads

  1. Convert DOC,XLS to PDF with Java
    By comm in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: July 2nd, 2013, 04:10 AM
  2. Java code Split text file into multiple text file
    By jayraj in forum What's Wrong With My Code?
    Replies: 26
    Last Post: April 19th, 2013, 06:14 AM
  3. Replies: 3
    Last Post: March 21st, 2013, 10:12 AM
  4. display text for 1 sec than remove txt java
    By hwoarang69 in forum Java Theory & Questions
    Replies: 35
    Last Post: March 16th, 2013, 12:31 PM
  5. Replies: 0
    Last Post: November 13th, 2012, 07:02 AM