實現網路列印工具類

2021-07-22 11:24:10 字數 4428 閱讀 1960

public class netprinter  catch (exception e) 

} else catch (exception e)

}return

ifopen;}

///

/// 網路印表機 關閉

///

///

///

public void

close() catch (exception e)

}///

/// 網路印表機 初始化印表機

///

public void

set() catch (ioexception e)

}///

/// 網路印表機 列印的文字

///

///

/// 0:居左 1:居中 2:居右

/// 字型大小0:正常大小 1:兩倍高 2:兩倍寬 3:兩倍大小 4:三倍高 5:三倍寬 6:三倍大小 7:四倍高 8:四倍寬 9:四倍大小 10:五倍高 11:五倍寬 12:五倍大小

/// 0:非針打 1:針打

public void

printtext(string pszstring, int nfontalign, int nfontsize, int ifzhenda) else

command = pszstring;

// +cmd_enter();

outbytes = command.getbytes(charset.forname("gb2312"));

//forname("utf-8")

stream.write(outbytes);

} catch (ioexception e)

}///

/// 網路印表機 回車

///

public void

printenter() catch (ioexception e)

}///

/// 網路印表機 切割

///

/// 切割時,走紙行數

public void

cutpage(int pagenum) catch (ioexception e)

}///

/// 網路印表機換行

///

///

public void

printnewlines(int lines)

} catch (ioexception e)

}///

/// 開啟錢箱

///

public void

openqianxiang() catch (ioexception e)

}///

/// 列印條碼

///

///

///

///

/// 1:上方 2:下方 0:不列印數字

/// 0:居左 1:居中 2:居右

/// 字型大小0:正常大小 1:兩倍高 2:兩倍寬 3:兩倍大小 4:三倍高 5:三倍寬 6:三倍大小 7:四倍高 8:四倍寬 9:四倍大小 10:五倍高 11:五倍寬 12:五倍大小

public void

printtiaoma(string numstr, int height, int width, int numweizi, int fontalign, int fontsize) catch (ioexception e)

}}class printercmd

///

/// 換行(回車)

///

///

public string cmd_enter()

///

/// 對齊模式

///

/// 0:左對齊 1:中對齊 2:右對齊

///

public string cmd_textalign(int align)

///

/// 字型的大小

///

/// 0:正常大小 1:兩倍高 2:兩倍寬 3:兩倍大小 4:三倍高 5:三倍寬 6:三倍大小 7:四倍高 8:四倍寬 9:四倍大小 10:五倍高 11:五倍寬 12:五倍大小

///

public string cmd_fontsize(int nfontsize)

return _cmdstr;

} ///

/// btp-m280(針打) 倍寬倍高

///

/// 0:取消倍寬倍高模式 1:倍高模式 2:倍寬模式 3:兩倍大小

///

public string cmd_fontsize_btp_m280(int size)

return _cmdstr;

} ///

/// btp-m280(針打) 倍寬倍高

///

/// 0:取消倍寬倍高模式 1:倍高模式 2:倍寬模式 3:兩倍大小

///

public string cmd_fontsize_btp_m2801(int size)

return _cmdstr;

} ///

/// 走紙

///

/// 走紙的行數

///

public string cmd_pagego(int line)

///

/// 切割

///

///

public string cmd_cutpage()

///

/// 返回狀態(返回8位的二進位制)

///

/// 1:印表機狀態 2:離線狀態 3:錯誤狀態 4:傳送紙狀態

/// 返回印表機狀態如下:

/// 第一位:固定為0

/// 第二位:固定為1

/// 第三位:0:乙個或兩個錢箱開啟 1:兩個錢箱都關閉

/// 第四位:0:聯機 1:離線

/// 第五位:固定為1

/// 第六位:未定義

/// 第七位:未定義

/// 第八位:固定為0

////// 返回離線狀態如下:

/// 第一位:固定為0

/// 第二位:固定為1

/// 第三位:0:上蓋關 1:上蓋開

/// 第四位:0:未按走紙鍵 1:按下走紙鍵

/// 第五位:固定為1

/// 第六位:0:印表機不缺紙 1: 印表機缺紙

/// 第七位:0:沒有出錯情況 1:有錯誤情況

/// 第八位:固定為0

////// 返回錯誤狀態如下:

/// 第一位:固定為0

/// 第二位:固定為1

/// 第三位:未定義

/// 第四位:0:切刀無錯誤 1:切刀有錯誤

/// 第五位:固定為1

/// 第六位:0:無不可恢復錯誤 1: 有不可恢復錯誤

/// 第七位:0:列印頭溫度和電壓正常 1:列印頭溫度或電壓超出範圍

/// 第八位:固定為0

////// 返回傳送紙狀態如下:

/// 第一位:固定為0

/// 第二位:固定為1

/// 第三位:0:有紙 1:紙將盡

/// 第四位:0:有紙 1:紙將盡

/// 第五位:固定為1

/// 第六位:0:有紙 1:紙盡

/// 第七位:0:有紙 1:紙盡

/// 第八位:固定為0

///

public string cmd_returnstatus(int num)

///

/// 條碼高寬

///

///

///

public string cmd_tiaomaheight(int num)

///

/// 條碼寬度

///

///

///

public string cmd_tiaomawidth(int num)

///

/// 條碼數字列印的位置

///

/// 1:上方 2:下方 0:不列印數字

///

public string cmd_tiaomaweizi(int num)

///

/// 開始列印(條碼型別為code39)

///

///

///

public string cmd_tiaomaprint(string numstr)

///

/// 開啟錢箱

///

///

public string cmc_qianxiang()

}

網路判斷工具類

package org.easycoding.mobile.android.utils import android.content.context import android.net.connectivitymanager import android.net.networkinfo publi...

網路工具類

public class netstateutils return false 判斷當前網路是否是wifi網路 param context return boolean public static boolean iswifi context context return false 判斷當前網路是...

Android工具類 關於網路 狀態的工具類

下方是乙個很好的監測網路 狀態的工具類 public class networkutils else return false gps是否開啟 param context return public static boolean isgpsenabled context context wifi是否...