Пример #1
0
//设置页长。毫米
func (jst *OkiPrinter) SetPageHeight(pos float32) error {
	utils.Trace("OkiPrinter received SetPageHeight request")
	var d int = int(pos / jst.lineinterval)
	var md int = d / 16
	var ld int = d % 16

	b := "1b46" + utils.FormatInt(md, 2, "0", 16) + utils.FormatInt(ld, 2, "0", 16)
	s, _ := hex.DecodeString(b)
	utils.Trace("OkiPrinter send SetPageHeight pi %x", s)
	if jst.checkJobInPrint() {
		return driverlayer.WriteData(jst.w, s)
	} else {
		return PR2NOTINJOB
	}
}
Пример #2
0
//直接进纸若干行。1B-0B-n1-n2(行数=n1×10+n2)
func (jst *OkiPrinter) AdvanceLine(pos uint) error {
	utils.Trace("OkiPrinter received PaperIn_some request")
	if pos < 10 {
		s, _ := hex.DecodeString("1B0B0" + utils.FormatInt(pos, 2, "0", 16))
	}
	if 9 < pos {
		s, _ := hex.DecodeString("1B0B" + utils.FormatInt(pos, 4, "0", 16))
	}
	utils.Trace("OkiPrinter send PaperIn_some pi %x", s)
	if jst.checkJobInPrint() {
		return driverlayer.WriteData(jst.w, s)
	} else {
		return PR2NOTINJOB
	}
}
Пример #3
0
//直接进纸n/120英寸。1B-25-35-n(01 =< n <= FF)
func (jst *OkiPrinter) SeekColPos(pos float32, currpos float32) error {
	if pos == 0 {
		utils.Trace("pos is zero ,skip")
		return nil
	}

	inch := int(utils.ConvertFrommmToInch(pos) * float32(120))
	remain := inch
	for {
		//oki的最大位移为255/120 inch
		if remain > 255 {
			s, _ := hex.DecodeString("1b2535ff")
			utils.Trace("OkiPrinter send AdvanceLine pi %x", s)
			if jst.checkJobInPrint() {
				driverlayer.WriteData(jst.w, s)
			} else {
				return PR2NOTINJOB
			}
			remain -= 255
		} else {
			var d uint8 = uint8(remain) & 0xff
			s, _ := hex.DecodeString("1b2535" + utils.FormatInt(int(d), 2, "0", 16) + "20")
			utils.Trace("OkiPrinter send AdvanceLine pi %x", s)
			if jst.checkJobInPrint() {
				return driverlayer.WriteData(jst.w, s)
			} else {
				return PR2NOTINJOB
			}
			break
		}
	}
	return nil
}
Пример #4
0
//设置有边界    单位:毫米
func (jst *OkiPrinter) SetRightMargin(pos float32) error {
	utils.Trace("OkiPrinter received SetRightMargin request")
	var l int = int(utils.ConvertFrommmToInch(pos) * float32(180))
	if l > 1690 {
		utils.Error("OkiPrinter ;s right margin is not allowed to exceed than 228.6mm !!")
		return PR2RIGHTTOOLARGE
	}
	utils.Trace("SetRightMargin:real right margin is %d/180 inch", l)
	b := "1b29" + utils.FormatInt(l, 4, "0", 16)
	s, _ := hex.DecodeString(b)
	utils.Trace("OkiPrinter send SetRightMargin pi %x", s)
	if jst.checkJobInPrint() {
		return driverlayer.WriteData(jst.w, s)
	} else {
		return PR2NOTINJOB
	}
}
Пример #5
0
//在一行内设置打印头水平方向绝对位置
func (jst *OkiPrinter) SeekRealLinePos(pos float32) error {
	if pos > 0 {
		line1 := int(pos)
		line := utils.FormatInt(line1, 4, "0", 16)

		s, _ := hex.DecodeString("1b2533" + line)

		if jst.checkJobInPrint() {
			return driverlayer.WriteData(jst.w, s)
		} else {
			return PR2NOTINJOB
		}

	} else {
		return PR2NOTIMPLEMENTED
	}
}
Пример #6
0
//设置n/120英寸行据。1B-25-39-n1-n2(n1为00,n2表示:00-FF/120)
func (jst *OkiPrinter) SetLineInterval(lineinterval float32) error {
	utils.Trace("OkiPrinter received SetLineInterval request")

	var line int
	line = int(utils.ConvertFrommmToInch(lineinterval) * float32(120))
	if line > 255 {
		return LINEINTERVALTOOLARGE
	}
	utils.Trace("SetLineInterval:line interval is %d/120 inch", line)
	s, _ := hex.DecodeString("1b2539" + utils.FormatInt(line, 4, "0", 16))
	utils.Trace("OkiPrinter send SetLineInterval pi %x", s)
	if jst.checkJobInPrint() {
		jst.lineinterval = lineinterval
		return driverlayer.WriteData(jst.w, s)
	} else {
		return PR2NOTINJOB
	}

}
Пример #7
0
//设置列距.是以列距为计算方式的(即字符间距)
//一般都是1/180
func (jst *OkiPrinter) SetColInterval(w float32) error {
	utils.Trace("OkiPrinter received SetColInterval request")

	var line int
	line = int(utils.ConvertFrommmToInch(w) * float32(jst.dotinstace)) //1/180
	if line > 255 {
		return LINEINTERVALTOOLARGE
	}
	utils.Trace("SetColInterval:col interval is %d/120 inch", line)

	realinterval := utils.FormatInt(line, 2, "0", 16)
	s, _ := hex.DecodeString("1c24" + realinterval)
	utils.Trace("OkiPrinter send SetColInterval pi %x", s)
	if jst.checkJobInPrint() {
		jst.colinterval = w
		return driverlayer.WriteData(jst.w, s)
	} else {
		return PR2NOTINJOB
	}

}