1

I am using the following code to convert firebase image(link) into pdf using iText. When i convert the text file the pdf generates but it is giving me error when i try to add image to pdf. When i open the generated pdf file it give error: "cannot display PDF(the file is of invalid format)" Here is the code:

    Document document = new Document();
            String outpath = Environment.getExternalStorageDirectory() + "/PDF2.pdf";
            try {
                FileOutputStream fos = new FileOutputStream(outpath);
                PdfWriter writer = PdfWriter.getInstance(document, fos);
                writer.open();
                document.open();
                document.add(Image.getInstance("https://firebasestorage.googleapis.com/v0/b/tharglobal-afe7d.appspot.com/o/files%2FPan%20Card%2FIMG-20190327-WA0003.jpg?alt=media&token=cd9ecd28-0c8a-4112-9c9a-80f04a3b17dd"));
                document.close();
                writer.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
Msb Says
  • 11
  • 1
  • 7

0 Answers0