首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过WIFI (ERROR_WRONG_LABEL)使用Brother进行安卓打印

通过WIFI (ERROR_WRONG_LABEL)使用Brother进行安卓打印
EN

Stack Overflow用户
提问于 2015-08-07 07:42:31
回答 1查看 3.7K关注 0票数 3

我正在创建一个Android应用程序,将打印到兄弟QL-720 QL标签打印机。我已经为此创建了一个示例项目。

我在libs文件夹中导入了必要的JAR文件,并按照Brother示例项目中的建议设置了打印机设置。然而,我一直收到一个错误,标签是不正确的。

我已经看到了关于类似问题的尝试使用Android Brother Sdk打印无线标签打印机时的标签线程。

根据“兄弟手册”,在我的情况下,labelNameIndex应该设置为5。

这是我的名单:

代码语言:javascript
复制
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

这是我的小演示项目的打印部分:

代码语言:javascript
复制
public void Print(){

    Printer myPrinter = new Printer();
    PrinterInfo myPrinterInfo = new PrinterInfo();
    PrinterStatus myPrinterStatus = new PrinterStatus();

    try{
        // Retrieve printer informations
        myPrinterInfo = myPrinter.getPrinterInfo();

        // Set printer informations
        myPrinterInfo.printerModel = PrinterInfo.Model.QL_720NW;
        myPrinterInfo.port=PrinterInfo.Port.NET;
        myPrinterInfo.printMode=PrinterInfo.PrintMode.FIT_TO_PAGE;
        myPrinterInfo.paperSize = PrinterInfo.PaperSize.CUSTOM;

        myPrinterInfo.ipAddress="192.168.0.193";
        myPrinterInfo.macAddress="00:00:00:00:00"; //hidden for security reasons

        LabelInfo mLabelInfo = new LabelInfo();
        mLabelInfo.labelNameIndex = 5;
        mLabelInfo.isAutoCut = true;
        mLabelInfo.isEndCut = true;
        mLabelInfo.isHalfCut = false;
        mLabelInfo.isSpecialTape = false;
        myPrinter.setPrinterInfo(myPrinterInfo);
        myPrinter.setLabelInfo(mLabelInfo);

        // Create bitmap
        Bitmap bmap = BitmapFactory.decodeResource(getResources(), R.drawable.printtest);

        try{
            tView.append("Start" + "\n" );

            myPrinter.startCommunication();
            PrinterStatus printerStatus = myPrinter.printImage(bmap);
            myPrinter.endCommunication();

            tView.append(printerStatus.errorCode.toString() + "\n");

        }catch(Exception e){
            tView.setText(e.toString());
        }

    }catch(Exception e){
        tView.setText(e.toString());
        //e.printStackTrace();
    }

}
EN

回答 1

Stack Overflow用户

发布于 2016-07-29 09:52:09

我也遇到了同样的问题,于是我决定:

代码语言:javascript
复制
printerInfo.printerModel = PrinterInfo.Model.QL_720NW;
printerInfo.port = PrinterInfo.Port.NET;
printerInfo.ipAddress = "...";

printerInfo.paperSize = PrinterInfo.PaperSize.CUSTOM;
printerInfo.paperPosition = PrinterInfo.Align.CENTER;
printerInfo.orientation = PrinterInfo.Orientation.LANDSCAPE;

printerInfo.labelNameIndex = LabelInfo.QL700.W50.ordinal();
printerInfo.isAutoCut = true;
printerInfo.isCutAtEnd = true;

但区别之处在于:

代码语言:javascript
复制
printerInfo.labelNameIndex = LabelInfo.QL700.W50.ordinal();

其中"W50“是纸张类型。您可以在manual.pdf中找到纸张类型id。

注意::我们必须使用序数值,而不是de值。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31872204

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档