Wednesday, February 29, 2012

Printing custom html from android app using PrinterShare


I am printing a custom html from my app using PrinterShare .



The reason why I'm using html is because, I'm changing the contents of the html by passing name value pairs through a query string. My html file is pretty simple and I have stored it under asset. When I try to access it as:




Intent i = new Intent(Intent.ACTION_VIEW);
i.setPackage("com.dynamixsoftware.printershare.amazon");
Uri printFileUri= Uri.parse("file:///android_asset/receipt-voucher.html?shopName=BTMShop&date=20/12/2007&serial=1121");
i.setDataAndType(printFileUri,"text/html");
startActivity(i);



The PrinterShare app is giving the web page unavailable error. So for testing purpose I created a text file under assest flder and tried to access it as-



Uri printFileUri= Uri.parse("file:///android_asset/test.txt");



and changed the data and type.



But even for the text file, I'm getting the error: No such file or directory from PrinterShare.



I have made the necessary additions in Manifest file.



Any idea?

No comments:

Post a Comment