1

I am developing a simple game using Swift ,UIKIt.

I am priting the end result of every game on a receipt that i make programatically.

I am using the Brother Bluetooth Thermal printer - RJ 3035B.

The printer succesfully prints one receipt and after printing it stops printing and the red (error) light keeps blinking.

I am trying different page sizes or change in pdf size but it is not helping.

Here is my code which i took from Brothers Swift sample:-

func printFinalPDF() {
        
        if(pdf_document == nil)
        {
            let alert = UIAlertController.init(title: "Alert", message: "Please select PDF file", preferredStyle: UIAlertController.Style.alert)
            let yesButton = UIAlertAction.init(title: "OK", style: UIAlertAction.Style.default, handler: {(alert: UIAlertAction!) in })
            
            alert.addAction(yesButton)
            self.present(alert, animated: true, completion: nil)
            return
        }
        
        let IsOpen = lib.openportMFI("com.issc.datapath")
        if(IsOpen == 1)
        {
            self.parseIndex()
            self.cmd()
            lib.closeport(5)
            print("")
            
            NSLog("%@",String.localizedStringWithFormat("%@", lib.printerstatus()! as CVarArg))
            let data = lib.printerstatus()
            print(data?.hexDescription)
            
        }
        
    }
    
    func parseIndex(){
        let _num = NSCharacterSet.decimalDigits;
        let _input = NSCharacterSet.init(charactersIn: PDF_PAGE)
        
        if(PDF_PAGE.count != 0)
        {
            if(_num.isSuperset(of: _input as CharacterSet))
            {
                PDF_PAGE_INT = Int(PDF_PAGE)!;
            }
            else
            {
                PDF_PAGE = "0";
                PDF_PAGE_INT = 0;
            }
        }
        else
        {
            PDF_PAGE = "0";
            PDF_PAGE_INT = 0;
            
        }
    }
    
    func cmd(){
        lib.setup("100", height: "140", speed: "14", density: "10", sensor: "1", vertical: "1", offset: "0")
        lib.sendcommand("SIZE 100 mm, 90 mm\r\n");
        if(PDF_PAGE_INT == 0){
            lib.printPDFbyFile(pdf_document, x: 0, y: 0, printer_dpi: 100)
        }
        else
        {
            lib.printPDFbyFile(pdf_document, x:0, y:0, printer_dpi:100, page_index:Int32(PDF_PAGE_INT))
        }
//        printWithWifi()
    }
arsh94deep
  • 11
  • 2
  • 1
    What does the Brother Printer Management Tool show? Have you read the trouble shooting chapter of the manual? – Risto Jan 02 '23 at 19:30

0 Answers0