-1

Is there any java library to convert my text file to an image file. can anyone help on this. For Example i have a text file name is "Test.txt". i want to convert that to "Test.jpg or Test.png".

is it possible?

Vikrant Kashyap
  • 6,398
  • 3
  • 32
  • 52
  • 1
    Do you want to rename the file? – devgianlu Apr 16 '19 at 11:48
  • 1
    What do you mean by "convert text file to an image file"? Lets say your `Text.txt` file contains many lines of text like `"this is some line\nand this is another line"` what kind of image do you want to get from it? Should image also represent that text (if so how big should it be, what font should it use, what is font color, background color, etc.)? – Pshemo Apr 16 '19 at 11:51
  • @Pshemo thanks for your reply. i want that whole file to be converted into an image.i want that whole text file as a image. – Anandasudhan T Apr 16 '19 at 12:52
  • Possibly related: [Convert text content to Image](https://stackoverflow.com/q/18800717) – Pshemo Apr 16 '19 at 15:59

1 Answers1

0

You could probably parse all of the text and write it onto a buffered image Graphics context and then pull all of the pixel data out and save it using ImageIO. It would require a lot of code to get the pagination down though. There is also ASF's FOP that can transform to Tiff/BMP (and a whole slew of other outputs) https://xmlgraphics.apache.org/fop/0.95/output.html#bitmap