#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    3
    Rep Power
    0

    How to convert .gif into .txt


    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.

    .gif to .pdf program is
    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
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,696
    Rep Power
    347
    convert that gif file into .txt or .doc file.
    To extract the images of letters that are shown by pixels in an image like a gif file as characters, you need a special program that can scan the image's pixels and figure out what letters are shown in the image so those letters can be written to a txt file.
    Ask a search engine for a character recognition program.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    3
    Rep Power
    0
    Originally Posted by NormR
    To extract the images of letters that are shown by pixels in an image like a gif file as characters, you need a special program that can scan the image's pixels and figure out what letters are shown in the image so those letters can be written to a txt file.
    Ask a search engine for a character recognition program.

    Thank you so much for replying....
    I will try for that.....
  6. #4
  7. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,298
    Rep Power
    7170
    The technology is usually called OCR or optical character recognition.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    3
    Rep Power
    0
    Originally Posted by E-Oreo
    The technology is usually called OCR or optical character recognition.
    Thanks for reply..
    Actually i want to a program in java to convert .gif to txt or .doc.

IMN logo majestic logo threadwatch logo seochat tools logo