KevinGong2013 / Printer

Swift ticket printer framework for ESC/POS-compatible thermal printers.
Apache License 2.0
144 stars 72 forks source link

How to Print Arabic Language #66

Open manojssas opened 1 year ago

manojssas commented 1 year ago

How can I print Arabic Language with Combination of English and Image?

KevinGong2013 commented 1 year ago

public extension String {

    struct ArabicEncoding {
        public static let windowsArabic = String.Encoding(rawValue: CFStringConvertEncodingToNSStringEncoding(CFStringEncoding(CFStringEncodings.windowsArabic.rawValue)))
    }
}

let receipt = Receipt(.🖨️58(String.ArabicEncoding.windowsArabic))
manojssas commented 1 year ago

@KevinGong2013 When we using this. The Print comment Goes to blank [] block to print Like

extension String: ReceiptItem {

public func assemblePrintableData(_ profile: PrinterProfile) -> [UInt8] {
    guard let data = self.data(using: profile.encoding) else {
        return []
    }
    return Array<UInt8>(data) + Command.CursorPosition.lineFeed.value
}

}

I am using this code :

    let receipt = Receipt(.🖨️58(String.ArabicEncoding.windowsArabic))
            <<< "٥ حلواني"
            <<< KV("٢ برجر", "٢ برجر")

    if bluetoothPrinterManager.canPrint {
        bluetoothPrinterManager.write(Data(receipt.data))
    }

public extension String {

struct ArabicEncoding {
    public static let windowsArabic = String.Encoding(rawValue: CFStringConvertEncodingToNSStringEncoding(CFStringEncoding(CFStringEncodings.windowsArabic.rawValue)))
}

}

But this is not working

Screenshot 2023-02-06 at 10 16 01 PM Screenshot 2023-02-06 at 10 16 14 PM Screenshot 2023-02-06 at 10 16 50 PM
manojssas commented 1 year ago

@KevinGong2013 Can you check and update me? Thanks

KevinGong2013 commented 1 year ago

You should confirm your device support Arabic.

manojssas commented 1 year ago

@KevinGong2013 Yes my device and printer both supports Arabic. App was live from previous 5 Years on App store which has support for Arabic language. And if we talk about the Printer. I am using X-Printer which supports Arabic language because in Android we are able to print Arabic language. Only iOS has issues.

manojssas commented 1 year ago

@KevinGong2013 Hi is there any way to Print Arabic language. Thanks in Advance

manojssas commented 1 year ago

Dear @KevinGong2013 Have you got any idea like how to print Arabic language? I do many changes inside Project but in Arabic mode this will print only blank.

Thanks