Convert image to PDF in Android

前端 未结 3 1729
故里飘歌
故里飘歌 2020-12-01 03:47

I need to send an image as in form of PDF file in my Android application but I dont have idea how to convert bitmap to PDF.

I am able to write pdf with text only.

3条回答
  •  囚心锁ツ
    2020-12-01 04:24

    use this

    Document document=new Document();
                PdfWriter.getInstance(document,new FileOutputStream("YourPDFHere.pdf"));
                document.open();
                Image image = Image.getInstance ("yourImageHere.jpg");
                document.add(new Paragraph("Your Heading for the Image Goes Here"));
                document.add(image);               
                document.close();
    

提交回复
热议问题