我跟随这打印样本接收。
这是我的Json数据
{
"response": {
"status": "http://www.neodynamic.com/articles/How-to-print-raw-ESC-POS-commands-from-PHP-directly-to-the-client-printer/php-print-esc-pos-sample-receipt.png"
}
}在这里,我分析了JOSN在其他一些activity..and中的意图。我将url/json响应分配给字符串"Test22"
现在Test22 = http://www.neodynamic.com/articles/How-to-print-raw-ESC-POS-commands-from-PHP-directly-to-the-client-printer/php-print-esc-pos-sample-receipt.png
所以我想把这个字符串添加到位图中。这样我才能打印..。
在爱普生公司的示例代码中,用于打印来自某个位置的图像,他们使用了
Bitmap logoData = BitmapFactory.decodeResource(getResources(), R.drawable.store);
StringBuilder textData = new StringBuilder();
final int barcodeWidth = 2;
final int barcodeHeight = 100;这里的示例是从R.drawable打印图像,但是我想从URL打印它,如果它打印后的存储应该删除图像.
有谁能给我建议一下我需要在R.drawable上添加什么.
实际上它是一个Pdf,我正在把它转换成一个图像。有人能建议我用PDF来绘制位图或打印图片吗.
发布于 2016-06-20 07:56:59
R.drawable只来自应用程序中的图片。
public static Bitmap getBitmapFromURL(String src) {
try {
URL url = new URL(src);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
Bitmap myBitmap = BitmapFactory.decodeStream(input);
return myBitmap;
} catch (IOException e) {
// Log exception
return null;
}
}更新:
从爱普生代码替换
Bitmap logoData = BitmapFactory.decodeResource(getResources(), R.drawable.store);至
Bitmap logoData = getBitmapFromURL("http://www.neodynamic.com/articles/How-to-print-raw-ESC-POS-commands-from-PHP-directly-to-the-client-printer/php-print-esc-pos-sample-receipt.png");https://stackoverflow.com/questions/37917009
复制相似问题