Thursday, June 7, 2012

Creating and Writing into PDF file android



Creating and writing a data into the PDF file on SD Card. It works for me. Any queries comment down.

byte[]= bytes;

File createfile = new File("/sdcard/Acc/");
createfile.mkdirs();
File outputFile = new File(createfile, "Payslip.pdf");
try 
{
  FileOutputStream fos = new FileOutputStream(outputFile);
 bytes = Base64.decode(strBinaryString, Base64.DEFAULT);
 String filepath = "/sdcard/Acc/Payslip.pdf";
 OutputStream pdffos;
 pdffos = new FileOutputStream(filepath);
 pdffos.write(bytes);
 pdffos.flush();
 pdffos.close();
 } 
 catch (FileNotFoundException e) 
 {
    e.printStackTrace();
 } 
 catch (IOException e) 
 {
    e.printStackTrace();
 }

No comments:

Post a Comment