star-micronics / react-native-star-io10

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

Problem designing the receipt [TSP100IIIU] #2

Closed creanordic closed 3 years ago

creanordic commented 3 years ago

We are having major problems with printing and cannot create spaces and having problems with designing the receipt. Can anybody help please? We purchased printer but cannot progress due to what seems is the SDK having bugs.

creanordic commented 3 years ago

Hoping that somebody will reply to this issue? @gare-bear @Lozrus @bandit-ibayashi Many thanks! :)

gare-bear commented 3 years ago

@creanordic sorry for the delayed response. Can you post what you've designed thus far using our StarXpandCommandBuilder? It will be much easier to debug if we can review your code.

Which printer are you using and have you seen our printing sample? https://github.com/star-micronics/react-native-star-io10/blob/c285b66a903125cbad7ccd582004fcaf429970e2/example/samples/printing/App.tsx#L56-L116

gelocreanordic commented 3 years ago

We used the sample codes provided. Here is the snippet: print.txt

Printer is TPS100IIIU.

Expected: It will print as exactly as it was in the commands.

Behavior: It only prints the qrcode as in the image below. 160267290_3063135433913762_1144053025512727733_n

gare-bear commented 3 years ago

@gelocreanordic, @creanordic I understand the problem now. The reason you're getting limited output is because the TSP100 is a Raster-only printer. It doesn't support many of the methods you're using which are geared towards text-based output. It does support QRCode because we can produce that graphically.

Instead of using ActionPrintText(...), you should use ActionPrintImage(...)

gelocreanordic commented 3 years ago

So the idea is to create an image based on my desired output then let it print through the printer using ActionPrintImage. will try this direction and will update

gare-bear commented 3 years ago

@gelocreanordic Were you able to figure it out?

kmamtora commented 3 years ago

Hi @gare-bear, I have 2 printers mPOP and TSP100IIIBI and code for printing receipts which i am using is

`var settings = new StarConnectionSettings();
      settings.interfaceType = printers[1].connectionSettings.interfaceType;
      settings.identifier = printers[1].connectionSettings.identifier;
      var printer = new StarPrinter(settings);
      try {

    var builder = new StarXpandCommand.StarXpandCommandBuilder();
    builder.addDocument(new StarXpandCommand.DocumentBuilder()
      .addPrinter(new StarXpandCommand.PrinterBuilder()
        .styleInternationalCharacter(StarXpandCommand.Printer.InternationalCharacterType.Usa)
        .styleCharacterSpace(0)
        .styleAlignment(StarXpandCommand.Printer.Alignment.Center)
        .actionPrintText("Star Clothing Boutique\n" +
          "123 Star Road\n" +
          "City, State 12345\n" +
          "\n")
        .styleAlignment(StarXpandCommand.Printer.Alignment.Left)
        .actionPrintText("Date:MM/DD/YYYY    Time:HH:MM PM\n" +
          "--------------------------------\n" +
          "\n")
        .actionPrintText("SKU         Description    Total\n" +
          "300678566   PLAIN T-SHIRT  10.99\n" +
          "300692003   BLACK DENIM    29.99\n" +
          "300651148   BLUE DENIM     29.99\n" +
          "300642980   STRIPED DRESS  49.99\n" +
          "300638471   BLACK BOOTS    35.99\n" +
          "\n" +
          "Subtotal                  156.95\n" +
          "Tax                         0.00\n" +
          "--------------------------------\n")
        .actionPrintText("Total     ")
        .add(new StarXpandCommand.PrinterBuilder()
          .styleMagnification(new StarXpandCommand.MagnificationParameter(2, 2))
          .actionPrintText("   $156.95\n")
        )
        .actionPrintText("--------------------------------\n" +
          "\n" +
          "Charge\n" +
          "156.95\n" +
          "Visa XXXX-XXXX-XXXX-0123\n" +
          "\n")
        .add(new StarXpandCommand.PrinterBuilder()
          .styleInvert(true)
          .actionPrintText("Refunds and Exchanges\n")
        )
        .actionPrintText("Within ")
        .add(new StarXpandCommand.PrinterBuilder()
          .styleUnderLine(true)
          .actionPrintText("30 days")
        )
        .actionPrintText(" with receipt\n")
        .actionPrintText("And tags attached\n" +
          "\n")
        .actionPrintText("--------------------------------\n" +
          "\n")
        .styleAlignment(StarXpandCommand.Printer.Alignment.Center)
        .actionPrintBarcode(new StarXpandCommand.Printer.BarcodeParameter('0123456',
          StarXpandCommand.Printer.BarcodeSymbology.Code128)
          .setBarDots(3)
          .setBarRatioLevel(StarXpandCommand.Printer.BarcodeBarRatioLevel.Level0)
          .setHeight(5)
          .setPrintHri(true))
        .actionFeedLine(1)
        .actionPrintQRCode(new StarXpandCommand.Printer.QRCodeParameter('Hello World.\n')
          .setModel(StarXpandCommand.Printer.QRCodeModel.Model2)
          .setLevel(StarXpandCommand.Printer.QRCodeLevel.L)
          .setCellSize(8))
        .actionFeedLine(1)
        .actionCut(StarXpandCommand.Printer.CutType.Partial)))

    var commands = await builder.getCommands();

    await printer.open();
    console.log(printer.information)
    console.log(`Printing receipts`);
    await printer.print(commands);
    console.log(`Success`);
  }
  catch (error) {
    console.log(`Error: ${String(error)}`);
  }
  finally {
    await printer.close();
    await printer.dispose();
  }` 

for mPOP it works as aspected but for TSP100IIIBI it does'nt print anything except Qrcode

can you guide me on this

759B0B29-3671-4AA5-9B29-411B0043E942

Lozrus commented 3 years ago

@kmamtora Due to differences in device capabilities, not all PrinterBuilder methods are available on every device. In particular, the TSP100 range does not have built-in font data, so is limited to printing graphically, and does not support the actionPrintText() method. Instead, if you require support for the TSP100 range, you will need to build up your document as images and add them to the print job with the actionPrintImage() method.

Please see the documentation for each method for device compatibility details, for example actionPrintText (in the "Supported Model" section near the top of the page).

kmamtora commented 3 years ago

@Lozrus Thanks will try it

gelocreanordic commented 3 years ago

Yes @gare-bear I just created an image and let the printer do its thing.

nguyen-vo commented 3 years ago

@gelocreanordic, were you able to generate an image file and store it in the drawable folder on the fly?