Printing pdf file from network shared printer in android

609 views Asked by At

I have a pdf file stored on my sd card named as "test.pdf". I have opened this file in my application using following code:

         b.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() +"/"+ "test.pdf");
        Intent target = new Intent(Intent.ACTION_VIEW);
        target.setDataAndType(Uri.fromFile(file),"application/pdf");
        target.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);

        Intent intent = Intent.createChooser(target, "Open File");
        try {
            startActivity(intent);
        } catch (ActivityNotFoundException e) {
            // Instruct the user to install a PDF reader here, or something
            Toast.makeText(getApplicationContext(), "not found", Toast.LENGTH_SHORT).show();
        }  
    }
});

PDF is displayed inside my application. Now i want to print this PDF file using my shared printer. How can I do that?

0

There are 0 answers