Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing from Android

Tags:

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.

like image 507
Ali Avatar asked Jun 20 '26 03:06

Ali


1 Answers

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#?"

like image 90
Satya Avatar answered Jun 21 '26 15:06

Satya