Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Creating a pdf using File writer

807603Dec 19 2007 — edited Dec 19 2007
I wanted to create a PDF doc out of a TXT file.... Before doing that, i just wanted to generate a PDF doc that contains a string in it. I did it using the following code:
try{
		FileWriter fr = new FileWriter("C:/WS_FTP.pdf");
		fr.write("hello");
		fr.close();
		}
I could see the PDF getting generated. But when i try to open that, i get a message saying that it is either corrupted or the fileType is not supported or it might be it was not decoded correctly.

I could open the file using TextPad. When i open it using TextPad, i could see the message - "hello" in it.

Can anyone resolve this problem?

If i want to convert the type of docs, how should i proceed... ? For eg., if i want to create hi.PDF from hi.TXT, what should i exactly do?

I was thinking to do in this way -

Put the data from the TXT to OutPutStream and write it in the new PDF doc... I am just giving it a try as i am not well versed in IO..
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 16 2008
Added on Dec 19 2007
5 comments
359 views