Create PDF object with MemoryFile Descriptor

32 views
Skip to first unread message

Aruna L.

unread,
Oct 7, 2013, 7:52:13 AM10/7/13
to apv-pdf...@googlegroups.com
Hi Friends,

I want to create a pdf file with MemoryFile without saving the file to the disk. I tried creating file as follow. But I'm getting invalid pdf file. Can anyone point the problem?

// create MemoryFile

ByteArrayOutputStream baos = new ByteArrayOutputStream();
boolean written = false;
try {

byte[] buff = new byte[512];

int len = 0;

int count = 0;

while ((len = is.read(buff)) != -1) {

baos.write(buff);

count += len;

}

memFile = new MemoryFile("oneinbox.pdf", count);

memFile.writeBytes(baos.toByteArray(), 0, 0, count);

written = true;
} catch (Exception e) {

Log.e(TAG, e.getMessage(), e);

} finally {

try {

memFile.close();

baos.flush();

baos.close();

is.close();

} catch (IOException e) {

Log.e(TAG, e.getMessage(), e);

}

}

 
Reply all
Reply to author
Forward
0 new messages