In this post i am going to explain you how to create PDF in your android application. This post is very use full for those who want to generate PDF in mobile directly without any help of external app. For this post i am using iText library you can download it from here and after download add this in your project.

Note: Please use iTextG library reaming part is save

Create PDF File in android

iText provides support for most advanced PDF features such as PKI-based signatures, 40-bit and 128-bit encryption, color correction, Tagged PDF, PDF forms (AcroForms), PDF/X, color management via ICC profiles and barcodes.

Step 1: Create a new project and add iText library to your project. To add library to your project go to: project ⇒ app ⇒ libs (paste your library .jar inside it and right click on your .jar add as library).

Step 2. Add read/write permission in your AndroidManifest.xml

Step 3: Now open your activity_main.xml and paste bellow code

Step 4: In your we have to create a method to generate PDF file. I create a new method createPDF() inside my file this is the main method which is responsible to generate PDF. Now to generate PDF we need to create layout so we create layout using iText table and cell

Sample code to work with iText Lib

After table is create we can add cell in it like this

If you want to add image in your cell you can do it in this way

Complete code to generate PDF



Hope this will help u 🙂