基础基础热敏打印功能
This commit is contained in:
parent
3bdf2b9849
commit
8e9c54b9b1
|
|
@ -90,6 +90,7 @@ public class PrintTestActivity extends AppCompatActivity implements View.OnClick
|
|||
findViewById(R.id.btn_print_column).setOnClickListener(this);
|
||||
findViewById(R.id.btn_print_demo1).setOnClickListener(this);
|
||||
findViewById(R.id.btn_print_demo2).setOnClickListener(this);
|
||||
findViewById(R.id.btn_print_alarm).setOnClickListener(this);
|
||||
findViewById(R.id.btn_print_test_page).setOnClickListener(this);
|
||||
findViewById(R.id.btn_check_paper).setOnClickListener(this);
|
||||
findViewById(R.id.btn_cut_all).setOnClickListener(this);
|
||||
|
|
@ -177,6 +178,8 @@ public class PrintTestActivity extends AppCompatActivity implements View.OnClick
|
|||
printDemo(false);
|
||||
} else if (id == R.id.btn_print_demo2) {
|
||||
printDemo(true);
|
||||
} else if (id == R.id.btn_print_alarm) {
|
||||
printAlarmNotice();
|
||||
} else if (id == R.id.btn_print_test_page) {
|
||||
sf.PrintTestPage();
|
||||
} else if (id == R.id.btn_check_paper) {
|
||||
|
|
@ -186,6 +189,43 @@ public class PrintTestActivity extends AppCompatActivity implements View.OnClick
|
|||
}
|
||||
}
|
||||
|
||||
private void printAlarmNotice() {
|
||||
// 1. 标题
|
||||
sf.PrintText("警情通知单", 2, 2, 40);
|
||||
sf.PaperCut();
|
||||
// 2. 二维码 (居中)
|
||||
sf.PrintQR("ALARM_20260304172432", 7, 2);
|
||||
sf.PrintText("\n", 1, 1, 20);
|
||||
sf.PaperCut();
|
||||
// 3. 详情列表
|
||||
sf.PrintText("报警时间: 2026-03-04 17:24:32", 1, 1, 20);
|
||||
sf.PrintText("报警人: 张先生", 1, 1, 20);
|
||||
sf.PrintText("报警人电话: 18722727636", 1, 1, 20);
|
||||
sf.PrintText("灾害地址: 贵州省安顺市西秀区(赵家山村)宋旗镇赵家山村", 1, 1, 20);
|
||||
sf.PrintText("警情分类: 抢险救援", 1, 1, 20);
|
||||
sf.PrintText("报警描述: 车祸", 1, 1, 20);
|
||||
sf.PrintText("主管救援站联系电话: 0851-33410119", 1, 1, 20);
|
||||
sf.PrintText("出动车辆: ", 1, 1, 20);
|
||||
|
||||
// 4. 分割线
|
||||
sf.PrintText("--------------------------------", 1, 1, 10);
|
||||
|
||||
// 5. 注意事项
|
||||
sf.PrintText("注意事项:", 1, 1, 20);
|
||||
sf.PrintText("1、请专职消防队人员穿戴好防护装备,携带灭火、救援器材赶往现场科学处置。", 1, 1, 20);
|
||||
sf.PrintText("2、到达现场后及时上报情况,注意安全,做好个人防护和现场警戒。", 1, 1, 20);
|
||||
sf.PrintText("3、根据现场情况迅速组织人员疏散,并在确保安全的前提下利用灭火救援装备开展救援。", 1, 1, 20);
|
||||
sf.PrintText("4、待责任消防救援站力量到达现场后,主动与其汇报现场已知情况,并协助做好灭火救援工作。", 1, 1, 20);
|
||||
sf.PrintText("5、严格落实作战行动安全规定,防止触电、溺水、烧伤、坠落、中毒、砸伤、放射线等伤害。", 1, 1, 20);
|
||||
|
||||
// 6. 结尾
|
||||
sf.PrintText("--------------------------------", 1, 1, 10);
|
||||
sf.PrintText("\n\n\n", 1, 1, 10);
|
||||
|
||||
// 7. 切纸
|
||||
sf.PaperCut();
|
||||
}
|
||||
|
||||
private void printDemo(boolean is3Inch) {
|
||||
int width = is3Inch ? 400 : 300;
|
||||
int right = is3Inch ? 120 : 100;
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@
|
|||
<Button android:id="@+id/btn_print_column" android:text="多列排版" android:layout_columnWeight="1"/>
|
||||
<Button android:id="@+id/btn_print_demo1" android:text="2寸样单" android:layout_columnWeight="1"/>
|
||||
<Button android:id="@+id/btn_print_demo2" android:text="3寸样单" android:layout_columnWeight="1"/>
|
||||
<Button android:id="@+id/btn_print_alarm" android:text="打印警情测试" android:layout_columnWeight="1" android:backgroundTint="#FF5722" android:textColor="#FFFFFF"/>
|
||||
<Button android:id="@+id/btn_print_test_page" android:text="打印自检" android:layout_columnWeight="1"/>
|
||||
<Button android:id="@+id/btn_check_paper" android:text="缺纸检测" android:layout_columnWeight="1"/>
|
||||
<Button android:id="@+id/btn_cut_all" android:text="全切纸" android:layout_columnWeight="1"/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue