star-micronics / react-native-star-io10

react-native-star-io10 is a library for supporting application development for Star Micronics devices.
Other
83 stars 54 forks source link

Issues with iOS 15.4.1: The printer only outputs blank sheet #63

Closed Knocky closed 2 years ago

Knocky commented 2 years ago

Description

A react native app which use react-native-star-io10 to print receipt. Before updating to iOS 15.4.1, application is still working normally. But after updating, it only outputs white paper.

Device where the bug occurs

Printer

Development environment

macOS

Code for reproduce

var builder = new StarXpandCommand.StarXpandCommandBuilder();
var printerBuilder = new StarXpandCommand.PrinterBuilder();

var imageParameter =  new StarXpandCommand.Printer.ImageParameter(imageSource, 576);
console.log('imageParameter = '+ JSON.stringify(imageParameter));

printerBuilder = printerBuilder
  .actionPrintImage(imageParameter,)
  .actionCut(StarXpandCommand.Printer.CutType.Partial);

builder.addDocument(
  new StarXpandCommand.DocumentBuilder().addPrinter(printerBuilder),
);

// Print.
var commands = await builder.getCommands();

console.log('commands = '+ commands);

await printer.open();
await printer.print(commands);

Variable imageParameter has the same value in all iOS version. But variable commands is different in iOS 15.4.1

Error

In iOS 15.4, imageParameter is right value but commands = await builder.getCommands(); return the following result:

commands = {
  "title": "StarXpandCommand",
  "version": "1.0.0",
  "contents": [
    {
      "category": "Document",
      "contents": [
        {
          "category": "Printer",
          "contents": [
            {
              "method": "Action.Print.Image",
              "parameter": {
                "source": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...( a lot of A )... AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<…>
...

and output empty receipt. (Paper is not upside down)

In other iOS version (e.g.15.0), the value of "source" consists of many other letters and can print normally.

Is there any way to fix this? Is react-native-star-io10 not supporting iOS 15.4 ?

bandit-ibayashi commented 2 years ago

@Knocky Thank you for your report. But I'm afraid I did not reproduce this phenomenon. I have prepared a sample program that is the same as yours and uses the StarXpandCommand.Printer.ImageParameter() method to print and cut only the image, but it prints the image successfully.

Here is my test environment.

Printer

Device

Environment

% npx react-native info
info Fetching system and libraries information...
System:
    OS: macOS 12.4
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
    Memory: 72.36 MB / 8.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.13.2 - ~/.nodebrew/current/bin/node
    Yarn: 1.22.17 - ~/.nodebrew/current/bin/yarn
    npm: 8.10.0 - ~/.nodebrew/current/bin/npm
    Watchman: 2022.05.16.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
    Android SDK:
      API Levels: 27, 30, 31, 32
      Build Tools: 30.0.2, 30.0.3, 32.0.0, 32.1.0
      System Images: android-31 | Google APIs Intel x86 Atom_64
      Android NDK: Not Found
  IDEs:
    Android Studio: 2021.1 AI-211.7628.21.2111.8193401
    Xcode: 13.4/13F17a - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.11 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.67.2 => 0.67.2 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

If possible, could you try React Native version 0.67.2?

Knocky commented 2 years ago

@bandit-ibayashi I'm sorry, there is a little mistake on the first comment, the error does not occur on Ipad. I try my app again with Ipad Mini 6 15.4 and it can print. Could you please try your sample program with iPhone 15.4 or 15.5 ?

bandit-ibayashi commented 2 years ago

@Knocky Thank you for the update. However, I am unable to reproduce this issue even though I am using iPhone X 15.4.1. Here is my test code which is based on our printing sample .

var printer = new StarPrinter(settings);

try {
    var builder = new StarXpandCommand.StarXpandCommandBuilder();
    builder.addDocument(new StarXpandCommand.DocumentBuilder()
    .addPrinter(new StarXpandCommand.PrinterBuilder()
        .actionPrintImage(new StarXpandCommand.Printer.ImageParameter("logo_01.png", 406))
        .actionCut(StarXpandCommand.Printer.CutType.Partial)
        )
    );

    var commands = await builder.getCommands();

    console.log('commands = ' + commands);

    await printer.open();
    await printer.print(commands);

    console.log(`Success`);
}
catch(error) {
    console.log(`Error: ${String(error)}`);
}
finally {
    await printer.close();
    await printer.dispose();
}

It is true that there are many 'A' in source parameter of Action.Print.Image, but not all of them were 'A'.

Would it be similarly a problem if you run our printing sample in your environment?

gare-bear commented 2 years ago

@Knocky can you post the imageSource or the image file you're using for printing?

Knocky commented 2 years ago

I found the cause. The problem was from my image source. The capture function returned an error raw string on IOS 15.4. Thank you for your support.