package com.printer.demo.utils;

import android.content.Context;
import android.util.Log;

import com.printer.demo.R;
import com.printer.sdk.PrinterConstants.LableFontSize;
import com.printer.sdk.PrinterConstants.LablePaperType;
import com.printer.sdk.PrinterConstants.PAlign;
import com.printer.sdk.PrinterConstants.PBarcodeType;
import com.printer.sdk.PrinterConstants.PRotate;
import com.printer.sdk.PrinterInstance;

public class PrintLabel75x60 {

    private static int MULTIPLE = 8;
    private static final int page_width = 75 * MULTIPLE;
    private static final int page_height = 60 * MULTIPLE;

    private static final String TAG = "PrintLabel";
    private static Context mContext;

    public PrintLabel75x60(Context context) {
        this.mContext = context;
    }

    public synchronized void doPrint(final PrinterInstance iPrinter,int printCount) {
            iPrinter.pageSetup(LablePaperType.Size_80mm, page_width, page_height);
            iPrinter.drawText(0, 0, page_width - 6 * 8, 50, PAlign.END, PAlign.CENTER, "控 市", LableFontSize.Size_48, 1, 0, 0, 0, PRotate.Rotate_0);
            iPrinter.drawText(0, 50, page_width -  6* 8, 120, PAlign.CENTER, PAlign.CENTER, "20005 "+printCount, LableFontSize.Size_64, 0, 0, 0, 0, PRotate.Rotate_0);
            iPrinter.drawText(0, 120, page_width - 8 * 8, 180, PAlign.CENTER, PAlign.CENTER, "广东佛山", LableFontSize.Size_64, 1, 0, 0, 0, PRotate.Rotate_0);
            iPrinter.drawLine(2, 0, 180, page_width - 8 * 8, 180, true);
            iPrinter.drawText(0, 185, 50, 235, PAlign.CENTER, PAlign.END, "区：", LableFontSize.Size_24, 0, 0, 0, 0, PRotate.Rotate_0);
            iPrinter.drawText(0, 235, 50, 285, PAlign.CENTER, PAlign.END, "收：", LableFontSize.Size_24, 0, 0, 0, 0, PRotate.Rotate_0);
            iPrinter.drawText(50, 185, "通讯城-华中通讯市", LableFontSize.Size_48, PRotate.Rotate_0, 1, 0, 0);
            iPrinter.drawText(50, 235, "刘航刘航", LableFontSize.Size_48, PRotate.Rotate_0, 1, 0, 0);
            iPrinter.drawText(0, 235, page_width - 8 * 8, 285, PAlign.END, PAlign.END, "件数：     ", LableFontSize.Size_24, 0, 0, 0, 0, PRotate.Rotate_0);
            iPrinter.drawText(0, 235, page_width - 8* 8, 285, PAlign.END, PAlign.END, "1/2", LableFontSize.Size_48, 1, 0, 0, 0, PRotate.Rotate_0);
            iPrinter.drawLine(2, 0, 285, page_width - 8* 8, 285, true);
            iPrinter.drawText(1, 290, "收：武汉转运场             2020-10-15 10：17", LableFontSize.Size_24, PRotate.Rotate_0, 0, 0, 0);
            iPrinter.drawText(1, 315, "发：东莞科苑城             收货单位：   刘航", LableFontSize.Size_24, PRotate.Rotate_0, 0, 0, 0);
            iPrinter.drawBarCode(0,page_height-130,page_width-6*8,page_height,PAlign.CENTER,PAlign.CENTER,0,0,"12345678912345678912345",PBarcodeType.CODE128,2,120,PRotate.Rotate_0);
            iPrinter.drawText(page_width - 7 * 8,400,"服务热线：400-9989-256",LableFontSize.Size_24,PRotate.Rotate_90,1,0,0);
            iPrinter.print(PRotate.Rotate_0, 1);
    }


}
