I am creating an application that will generate a PDF on Android (with itextg
library) without storing it, just to show the info as a PDF.
I have the following code to generate the PDF:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Document document = new Document();
PdfWriter pdfWriter = PdfWriter.getInstance(document, baos);
document.open();
document.add(new Paragraph("Hello world"));
document.close();
byte[] pdfByteArray = baos.toByteArray();
and it works fine but I could not find a working example that work for me (using a ByteArrayOutputStream
). These are the questions that I have looked:
- Need help to convert a Pdf page into Bitmap in Android Java
- How to render PDF in Android
- How to read a pdf in android
- PDF to byte array and vice versa
- PDF text extraction using iText
but with any of their responses I have been able to show the PDF on Android.
How can I visualize the PDF that I have generated in my Android application?
Thanks in advance!