Last active
May 18, 2018 06:40
-
-
Save frankyxhl/bcbfbd06c51a1de9f055b28156023d0e to your computer and use it in GitHub Desktop.
Brother RJ-3050AI ERROR CODE -34 problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code works | |
// BRSimplePrintViewController.swift | |
// SDK_Sample_Swift | |
// | |
// Copyright © 2017 Brother Industries, Ltd. All rights reserved. | |
// | |
import Foundation | |
import UIKit | |
class BRSimplePrintViewController: UIViewController, BRSelectDeviceTableViewControllerDelegate { | |
var selectedDeviceInfo : BRPtouchDeviceInfo? | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
} | |
// Select Device | |
@IBAction func selectButtonTouchDown(_ sender: Any) { | |
self.performSegue(withIdentifier: "goSelectDeviceSegue", sender: nil) | |
} | |
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
if(segue.identifier == "goSelectDeviceSegue") { | |
guard let selectDeviceTableViewController = segue.destination as? BRSelectDeviceTableViewController else { | |
print("Prepare for Segue Error") | |
return | |
} | |
selectDeviceTableViewController.delegate = self | |
} | |
} | |
func setSelected(deviceInfo: BRPtouchDeviceInfo) { | |
selectedDeviceInfo = deviceInfo | |
} | |
@IBAction func printButtonTouchDown(_ sender: Any) { | |
guard let img = UIImage(named: "100×200.bmp") else {return} | |
guard let modelName = selectedDeviceInfo?.strModelName else {return} | |
let venderName = "Brother " | |
let dev = venderName + modelName | |
guard let num = selectedDeviceInfo?.strSerialNumber else {return} | |
self.printImage(image: img, deviceName: dev, serialNumber: num) | |
} | |
func printImage (image: UIImage, deviceName: String, serialNumber: String) { | |
guard let ptp = BRPtouchPrinter(printerName: deviceName, interface: CONNECTION_TYPE.BLUETOOTH) else { | |
print("*** Prepare Print Error ***") | |
return | |
} | |
ptp.setupForBluetoothDevice(withSerialNumber: serialNumber) | |
ptp.setPrintInfo(self.settingPrintInfoForQL()) | |
let filepath = Bundle.main.path(forResource: "rj3050ai_76mm", ofType: "bin") | |
let paperWidth = ptp.setCustomPaperFile(filepath) | |
// print("paper width:") | |
// print(paperWidth) | |
guard ptp.isPrinterReady() else { | |
print("*** Printer is not Ready ***") | |
return | |
} | |
if ptp.startCommunication() { | |
let result = ptp.print(image.cgImage, copy: 1) | |
if result != ERROR_NONE_ { | |
print ("*** Printing Error ***") | |
} | |
ptp.endCommunication() | |
} | |
else { | |
print("Communication Error") | |
} | |
} | |
func settingPrintInfoForPJ() -> BRPtouchPrintInfo { | |
let printInfo = BRPtouchPrintInfo() | |
printInfo.strPaperName = "80mm" | |
printInfo.nDensity = 0 | |
printInfo.nOrientation = ORI_PORTRATE | |
printInfo.nPrintMode = PRINT_FIT | |
printInfo.nAutoCutFlag = OPTION_AUTOCUT | |
printInfo.nExtFlag = EXT_PJ700_FP | |
printInfo.bBidirection = true | |
printInfo.bOverWrite = false | |
return printInfo | |
} | |
func settingPrintInfoForQL() -> BRPtouchPrintInfo { | |
let printInfo = BRPtouchPrintInfo() | |
printInfo.strPaperName = "80mm" | |
printInfo.nPrintMode = PRINT_FIT | |
printInfo.nAutoCutFlag = OPTION_AUTOCUT | |
return printInfo | |
} | |
func settingPrintInfoForPT() -> BRPtouchPrintInfo { | |
let printInfo = BRPtouchPrintInfo() | |
printInfo.strPaperName = "80mm" | |
// printInfo.nPrintMode = PRINT_FIT | |
// printInfo.nAutoCutFlag = OPTION_AUTOCUT | |
printInfo.nDensity = 0 | |
printInfo.bEndcut = false | |
printInfo.bBidirection = false | |
printInfo.bOverWrite = false | |
return printInfo | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment