java使用jnative控制北洋牌标签打印机打印二维码

原文http://cfanz.cn/index.php?c=article&a=read&id=31629
时间:2012-11-20 17:10:02 打印机型号BTP-2100E,可打印二维码标签,效果如附件,将打印机的驱动bpladll.dll、ByUSBInt.dll和jnative的dll放到system32下面,项目导入jnative的jar包,使用USB接口
import org.xvolks.jnative.JNative;
import org.xvolks.jnative.Type;
import org.xvolks.jnative.exceptions.NativeException;

public class CopyOfDemo {

private static final String PRINTER_DLL = "bpladll.dll";

public static void main(String[] args) {
Demo demo = new Demo();
System.loadLibrary("bpladll");
JNative n = null;
try {

// 打开端口
n = demo.getJNativeByFunction("BPLA_OpenUsb");
n.setRetVal(Type.INT);
n.setParameter(0, Type.INT, "1");
n.invoke();
System.out.println(n.getRetVal() + ":BPLA_OpenUsb");

n = demo.getJNativeByFunction("BPLA_SetEnd");
n.setRetVal(Type.INT);
n.setParameter(0, Type.INT, "70");
n.invoke();
System.out.println(n.getRetVal() + ":BPLA_SetEnd");

n = demo.getJNativeByFunction("BPLA_Reset");
n.setRetVal(Type.INT);
n.invoke();
System.out.println(n.getRetVal() + ":BPLA_Reset");

n = demo.getJNativeByFunction("BPLA_StartArea");
n.setRetVal(Type.INT);
n.setParameter(0, Type.INT, "0");
n.setParameter(1, Type.INT, "500");
n.setParameter(2, Type.INT, "10");
n.setParameter(3, Type.INT, "10");
n.setParameter(4, Type.INT, "0");
n.setParameter(5, Type.INT, "0");
n.setParameter(6, Type.INT, "0");
n.setParameter(7, Type.INT, "0");
n.invoke();
System.out.println(n.getRetVal() + ":BPLA_StartArea");

n = demo.getJNativeByFunction("BPLA_PrintTruetype");
n.setRetVal(Type.INT);
n.setParameter(0, Type.STRING, "南京咸水鸭");
n.setParameter(1, Type.INT, "4");
n.setParameter(2, Type.INT, "210");
n.setParameter(3, Type.STRING, "微软雅黑体");
n.setParameter(4, Type.INT, "30");
n.setParameter(5, Type.INT, "0");
n.invoke();
System.out.println(n.getRetVal() + ":BPLA_PrintTruetype");

n = demo.getJNativeByFunction("BPLA_PrintTruetype");
n.setRetVal(Type.INT);
n.setParameter(0, Type.STRING, "价格(元):35");
n.setParameter(1, Type.INT, "4");
n.setParameter(2, Type.INT, "180");
n.setParameter(3, Type.STRING, "微软雅黑体");
n.setParameter(4, Type.INT, "20");
n.setParameter(5, Type.INT, "0");
n.invoke();
System.out.println(n.getRetVal() + ":BPLA_PrintTruetype");

n = demo.getJNativeByFunction("BPLA_PrintTruetype");
n.setRetVal(Type.INT);
n.setParameter(0, Type.STRING, "净重(千克):2.6");
n.setParameter(1, Type.INT, "4");
n.setParameter(2, Type.INT, "150");
n.setParameter(3, Type.STRING, "微软雅黑体");
n.setParameter(4, Type.INT, "20");
n.setParameter(5, Type.INT, "0");
n.invoke();
System.out.println(n.getRetVal() + ":BPLA_PrintTruetype");

n = demo.getJNativeByFunction("BPLA_PrintTruetype");
n.setRetVal(Type.INT);
n.setParameter(0, Type.STRING, "单价(元/千克):15");
n.setParameter(1, Type.INT, "4");
n.setParameter(2, Type.INT, "120");
n.setParameter(3, Type.STRING, "微软雅黑体");
n.setParameter(4, Type.INT, "20");
n.setParameter(5, Type.INT, "0");
n.invoke();
System.out.println(n.getRetVal() + ":BPLA_PrintTruetype");

n = demo.getJNativeByFunction("BPLA_PrintTruetype");
n.setRetVal(Type.INT);
n.setParameter(0, Type.STRING, "生产日期:12.11.20");
n.setParameter(1, Type.INT, "4");
n.setParameter(2, Type.INT, "90");
n.setParameter(3, Type.STRING, "微软雅黑体");
n.setParameter(4, Type.INT, "20");
n.setParameter(5, Type.INT, "0");
n.invoke();
System.out.println(n.getRetVal() + ":BPLA_PrintTruetype");

n = demo.getJNativeByFunction("BPLA_PrintTruetype");
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       标签: 二维码 java jnative 控制 北洋 标签 印机 二维 相关信息更多
•二维码项目ZXing在Java中的使用•Java实现二维码QRCode的编码和解码•java生成二维码•Java利用Zxing生成二维码•java版二维码实例(非安卓版)•java生成二维码方法事例•JAVA 生成二维码 代码•[原创]解决某物流企业二维码打印问题•使用google的zxing制作二维码•Android Market 链接的生成与分享•使用google的zxing类生成一维码、二维码实例•QQ2013 Beta 3 (1.91.6565)发布,全面升级讨论组功能•Java 二维数组练习-----字符界面的扫雷•使用xml和java代码混合控制UI界面•Java乔晓松-JSP标准标签库•Java中log4j控制写入日志开关 {#if  $T.total > 0 && $T.page <= $T.pageNum}
<ul>
   {#foreach $T.data as r}
   <li>
   <div class="fl l">
  <img alt="{$T.r.nickname ? $T.r.nickname : '匿名'}" src="{#if $T.r.user_icon.url !== ''}{$T.r.user_icon.url}{#else}style/classic/web/images/user_normal.jpg{#/if}">
   </div>
   <div class="fl r">
  <div class="prop"><span>{$T.r.formt_tm}</span>{#if $T.r.nickname}<a href="index.php?c=uc/main&id={$T.r.userid}">{$T.r.nickname}</a>{#else}<span class="user_name">匿名</span>{#/if}</div>
  <div class="pc">{$T.r.content}</div>
   </div>
   <div class="clear"></div>
   </li>
   {#/for}
</ul>
<div class="page-bar">
<div class="fl">
{#if $T.page > 1 && $T.pageNum > 1)
<a href="javascript:void(0);" page="{$T.page > 1 ? $T.page -1 : 1}">上一页</a>
{#/if}
<a href="javascript:void(0);" page="1"  {$T.page == 1 ? 'class="actived"' : ''}>1</a>
{#if  $T.s_num > 2}
<span>...</span>
{#/if}
{#for index = $T.s_num to $T.e_num}
<a href="javascript:void(0);" page="{$T.index}" {$T.page == $T.index ? 'class="actived"' : ''}>{$T.index}</a>
{#/for}
{#if  $T.pageNum > $T.pageNavSize+ 2 && $T.s_num != $T.pageNum - $T.pageNavSize}
<span>...</span>
{#/if}
{#if $T.pageNum > 1}
<a href="javascript:void(0);" page="{$T.pageNum}" {$T.page == $T.pageNum ? 'class="actived"' : ''}>{$T.pageNum}</a>
{#/if}
{#if $T.pageNum != $T.page && $T.pageNum > 1}
<a href="javascript:void(0);" page="{$T.page < $T.pageNum ? $T.page+1 : $T.pageNum}">下一页</a>
{#/if}
</div>
<div class="clear"></div>
</div>
{#/if}

你可能感兴趣的:(jnative)