0

I need to convert memo file(text) to pdf in my android application. I went through few tutorials related to iText, but all of them added content to the pdf in their code. But what I need is convert the memo file exact as it is. Can I do this using iText or is their any other way to do this?

IBunny
  • 309
  • 9
  • 20

1 Answers1

0

Get the string out of text file and use this method to write string to pdf.

String s="text to be written";
 byte[] bytes= javax.xml.bind.DatatypeConverter.parseBase64Binary(s);
 FileOutputStream fos = new FileOutputStream("pathname.pdf"); 
 try{
 fos.write(bytes); 
 }catch(Exception e){}
 finally{
 fos.close();
  }

or, you may use external libraries like :

http://code.google.com/p/xspdf/

and use it as

  String s="text to be writen";
  XSPDF .getInstance (). print ( s). createPdf ( "pdf/Example 002.pdf" );
  • Thanks but what I need is to convert text file into pdf. It is not a string variable. I don't know the content of the text file some times it may be big. What I have to do is just convert the file in to pdf. – IBunny Jan 07 '14 at 05:55
  • Did you ever use this in android? It require java.awt.Color which we cannot use in Android. – IBunny Jan 17 '14 at 01:22