I am making a module that needs to scan from an image taken by the camera. so basically, it converts jpeg into a PDF.
I am done accessing the camera and retrieving the bitmap too. my problem is how to get the URI and pass it to the class that converts it to the pdf. It does not give any errors in android monitor so i don't know what i'm doing wrong.
below is my code:
public void selectImages() {
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
startActivityForResult(intent, CAMERA_REQUEST);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == INTENT_REQUEST_GET_IMAGES && resultCode == Activity.RESULT_OK)
{
photo = (Bitmap) data.getExtras().get("data");
uri = data.getData();
if(uri.equals(""))
{
Toast.makeText(AddUtility.this, "empty", Toast.LENGTH_SHORT).show();
} else {
CreatePDF();
}
}
}
public void CreatePDF()
{
Document document = new Document(PageSize.A4, 38, 38, 50, 38);
try{
PdfWriter.getInstance(document,new FileOutputStream("Sample.pdf"));
document.open();
Image image = Image.getInstance (uri.getPath());
document.add(new Paragraph("Heading"));
document.add(image);
document.close();
} catch (Exception e)
{
e.printStackTrace();
Toast.makeText(AddUtility.this, e.toString(), Toast.LENGTH_SHORT).show();
}
}