Convert PNG to PDF

[ ]

Aspose.PDF for Android via Java support feature to convert PNG images to PDF format. Check the next code snippet for realizing you task.

PNG refers to a type of raster image file format that use loseless compression, that makes it popular among its users.

You can convert PNG to PDF image using the below steps:

  1. Load input PNG image
  2. Read height and width values
  3. Create new document and add Page
  4. Set page dimensions
  5. Save output file

Moreover, the code snippet below shows how to convert PNG to PDF in your Java applications:

    public void convertPNGtoPDF () {
        // Initialize document object
        document=new Document();

        Page page=document.getPages().add();
        Image image=new Image();

        File imgFileName=new File(fileStorage, "Conversion/sample.png");

        try {
            inputStream=new FileInputStream(imgFileName);
        } catch (FileNotFoundException e) {