In my application i want to convert the images selected by the user into one single PDF file. I am using iText library as suggested by many people. The user selects multiple images and one pdf is created with it where each image is 1 pdf page.
The Code i am using is give as below
Document document = new Document(PageSize.A4);
try {
String path = Environment.getExternalStorageDirectory()+"/PDFile.pdf";
File file= new File(path);
if(file.exists())
{
}
else
{
file.createNewFile();
}
PdfWriter.getInstance(document,new FileOutputStream(path));
document.open();
for(int i =0; i<pdfImage.size();i++)
{
Image image = Image.getInstance(pdfImage.get(i));
image.scaleAbsolute(PageSize.A4);
image.setAbsolutePosition(0, 0);
document.add(image);
}
document.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
The pdf is getting generated but the image is cropped. Only half of the image is visible rest of it is cropped.
Do i have to set anything for the pdf to adopt to the image size ??
Or do i have to change or resize the image to adopt to pdf page size??
Please help!! I have no idea how to resolve this???