Ali
Ali

Reputation: 1678

Printing from Android

Is there any Simple and Sweet solution for Printing a simple text file or Image from Android?

I've seen Print 2 Share but it's not free and didn't find any other API for it.

Upvotes: 3

Views: 4194

Answers (1)

Satya
Satya

Reputation: 146

Use this intent and PrinterShare

Android developer, you can easily integrate your application with PrinterShare to provide printing capabilities to your users. We use intent mechanism to trigger print jobs on the phone. You can inject the following code into your app at the place where printing is required:

   Intent i = new Intent(Intent.ACTION_VIEW);
    i.setPackage("com.dynamixsoftware.printershare");
    i.setDataAndType(data_uri, data_type);
    startActivity(i);

Where:

data_uri - Uri of the object to print, such as "file:///sdcard/something.pdf" or "content://something"

data_type - Mime type. The following mime types are supported:

"application/pdf"
"text/html"
"text/plain"
"image/png"
"image/jpeg"
"application/msword" - .doc
"application/vnd.openxmlformats-officedocument.wordprocessingml.document" - .docx
"application/vnd.ms-excel" - .xls
    "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" - .xlsx
    "application/vnd.ms-powerpoint" - .ppt
    "application/vnd.openxmlformats-officedocument.presentationml.presentation" - .pptx

http://www.printershare.com/help-android-integration.sdf

https://play.google.com/store/apps/details?id=com.dynamixsoftware.printershare&feature=more_from_developer#?"

Upvotes: 1

Related Questions