Convert PNG to PDF
Contents
[
Hide
]
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:
- Load input PNG image
- Read height and width values
- Create new document and add Page
- Set page dimensions
- 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) {
resultMessage.setText(e.getMessage());
return;
}