I am using ITextPDF to create a PDF.The PDF is created in android. I would NOT like to save the pdf to the local storage of the android device, instead I would like to save it to a variable, like File file; or something similar, or directly convert it to a string and then save that value to a database.
This is where I declare the File variable(this can change)
File file;
This is the button that executes the pdf creation.
PDFTest.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PDF();
}
});
This is the method to create the PDF
public void PDF()
{
try {
Image img = Image.getInstance(IMAGES[0]);
Document document = new Document(img);
PdfWriter.getInstance(document, new FileOutputStream(file));
document.open();
document.add(new Paragraph("Example"));
document.close();
}catch (DocumentException e)
{
e.printStackTrace();
} catch (FileNotFoundException e)
{
e.printStackTrace();
}
}
The FileOutputStream requires a location which I just made file. If the file is correct, how can I display the values from that file object.