【问题标题】:Print an image using don's Bluetooth Serial Plugin使用 don 的蓝牙串行插件打印图像
【发布时间】:2017-09-19 05:48:25
【问题描述】:

我有一台 Epson TM-P20 热敏打印机。我使用this link 将文本从 ionic 3 应用程序打印到打印机。我的问题是,我不知道如何使用这个插件打印图像。

我使用WebAPI2作为我的网络服务,我加载了图像并将图像转换为base64,

public string getLogo()
    {
        var file = System.Web.Hosting.HostingEnvironment.MapPath(@"~/App_Data/logocogbw.png");
        return Convert.ToBase64String(File.ReadAllBytes(file));
}

如何使用此插件打印图像?任何帮助,将不胜感激。

【问题讨论】:

    标签: angular ionic2 asp.net-web-api2 cordova-plugins ionic3


    【解决方案1】:

    更新答案:

    Owner of the plugin 是这么说的:

    您可能需要将图像转换为打印机可以使用的格式 理解。可能是 PCL 或 PostScript 之类的东西?

    这个插件可以发送二进制数据。 write 方法接受文本或 二进制数据。请参阅文档中的快速示例 https://github.com/don/BluetoothSerial#write

    另一个useful link

    旧答案:

    你需要这样做:

    let data=this.getLogo();//get image data
    this.bluetoothSerial.write(data).then(success, failure);// write into port using Bluetooth
    

    【讨论】:

    • 感谢您的回复。我试了一下,打印机将base64数据打印为文本。
    • 你不能直接做请看更新后的帖子。
    • 是否可以通过 ESC/POS 命令打印?我发现GS ( L / GS 8 L这个命令必须与打印图像有关
    • 我会尝试编写自己的插件。我不知道我是否可以使它工作。 :(
    猜你喜欢
    • 1970-01-01
    • 2021-11-22
    • 1970-01-01
    • 1970-01-01
    • 2011-12-28
    • 2018-11-14
    • 1970-01-01
    • 2016-06-23
    • 1970-01-01
    相关资源
    最近更新 更多