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

Printing a blank sheet of paper #62

Closed bhimanshu-kalra closed 2 years ago

bhimanshu-kalra commented 2 years ago

Description

I have tried using actionPrintImage and actionPrintText but none seems to work, on android and IOS both.

Your printer

Code

actionPrintImage

var settings = new StarConnectionSettings();
settings.interfaceType = interfaceType;
identifier && (settings.identifier = identifier);

var printer = new StarPrinter(settings);

try {
    const builder = new StarXpandCommand.StarXpandCommandBuilder();
    builder.addDocument(
        new StarXpandCommand.DocumentBuilder().addPrinter(
            new StarXpandCommand.PrinterBuilder()
                .actionPrintImage(
                    new StarXpandCommand.Printer.ImageParameter(
                        imageUri,
                        400,
                    ),
                )
                .actionCut(StarXpandCommand.Printer.CutType.Partial),
        ),
    );
    const commands = await builder.getCommands();

    await printer.open();
    await printer.print(commands);
} catch (error) {
    console.log(error);
} finally {
    await printer.close();
    await printer.dispose();
}

actionPrintText

var settings = new StarConnectionSettings();
settings.interfaceType = interfaceType;
identifier && (settings.identifier = identifier);

var printer = new StarPrinter(settings);

try {
    const builder = new StarXpandCommand.StarXpandCommandBuilder();
    builder.addDocument(
        new StarXpandCommand.DocumentBuilder().addPrinter(
           new StarXpandCommand.PrinterBuilder().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',
            ),
        ),
    );
    const commands = await builder.getCommands();

    await printer.open();
    await printer.print(commands);
} catch (error) {
    console.log(error);
} finally {
    await printer.close();
    await printer.dispose();
}

Additional context

I can successfully connect to the printer, but nothing is printed on the paper. Just a blank sheet of paper comes out of the printer. Thanks in advance!

gare-bear commented 2 years ago

@bhimanshu-kalra This can happen when you have the paper roll upside down. Try flipping the roll over.