将memo(text)文件转换为android中的pdf文件

时间:2013-12-27 04:29:09

标签: java android itext

我需要在我的Android应用程序中将备忘录文件(文本)转换为pdf。我浏览了一些与iText相关的教程,但是所有这些教程都在代码中添加了pdf内容。但我需要的是准确地转换备忘录文件。我可以使用iText执行此操作,还是以其他任何方式执行此操作?

1 个答案:

答案 0 :(得分:0)

从文本文件中获取字符串并使用此方法将字符串写入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();
  }

,或者 您可以使用以下外部库:

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

并将其用作

  String s="text to be writen";
  XSPDF .getInstance (). print ( s). createPdf ( "pdf/Example 002.pdf" );
相关问题