ReactJs does not create recipt from POS Printer












0















I want to print a receipt with EPSON TM-T82.



I am creating a restaurant app using given laravel API and ReactJS Front End. For the Bill or Invoice printing, I use jsPDF to print bill with thermal printer. jsPDF uses some paper sizes (A4, A3, legal ...). But there is not thermal printer paper which is 4 inch width and a roll of height.



The print object will be given by an array/json. The sample bill format as follows.



What I tried



import React from 'react';
import * as jsPDF from 'jspdf'

class JSPDFTest extends React.Component
{
constructor(props)
{
super(props);
this.printPDF = this.printPDF.bind(this);
}

printPDF()
{
var specialElementHandlers = {
'#myId': function(element, renderer)
{
return true;
},
};

var pdf = new jsPDF();

pdf.text(10, 10, 'Hello World');

pdf.save('Test.pdf');
}

render()
{
return (
<div>
<div id="myId">
<h2> HTML to PDF</h2>
<p> A sample HTML to PDF</p>
</div>
<button onClick = {this.printPDF}> Download PDF </button>
</div>
);
}
}

export default JSPDFTest;


Bill requirements




  • The header (Restaurant name, Address, Contact and Date/Time, Counter, Bill no) should be center alignment.

  • After the total items, horizontal separated should be there.

  • The text Net Total, CASH and Balance should be right alignment and those amounts in right alignment.

  • Finally notice should be printed with the title as above --- IMPORTANT NOTICE ---.


Bill format



|             ABC Restaurant            | }
| Sunny Road, Canada | }
| Contact : 123456789 | } // This is header should be centered
| | }
| 13/11/2018 12:45:49 SAKTHY No: 59 | }
|---------------------------------------|
| NO | ITEM | PRICE | QTY | AMOUNT |
|:--:|:-------:|:------:|:---:|--------:| }
| 1 The big tasty Pizza | }
| ET4565 500.00 2.00 1000.00 | }
| 2 Crunchy huge Buggers | } // Item name in first line others next line
| BG8765 250.00 2.00 500.00 | } // PRICE and AMOUNT right aligned
| 3 1.5 l Coca-Cola pack | }
| CC9874 50.00 5.00 250.00 | }
|---------------------------------------|
| Net Total 1750.00 | }
| | }
| CASH 2000.00 | }
| Balance 250.00 | }
|-----------IMPORTANT NOTICE-----------| } // Footer monetary values right aligned
| In case of a price discrepancy return | }
| the bill and item within 2 day to | }
| refund the difference | }


Questions :




  • How to set random paper size, I read Aidiakapi here

  • Contents should be in the correct alignment (e.g: Prices right aligned).

  • One click to print


Sample json or array



{
"header": {
"invoice": "59",
"name": "ABC Restaurant",
"address": "Sunny Road, Canada",
"contact": "123456789",
"date": "13/11/2018 12:45:52",
"counter": "SAKTHY"
},
"items": [{
"no": "1",
"item": "The big tasty Pizza",
"price": "500.00",
"qty":"2.00",
"amount":"1000.00"
},
{
"no": "2",
"item": "Crunchy huge Buggers",
"price": "250.00",
"qty":"2.00",
"amount":"500.00"
},
{
"no": "3",
"item": "1.5 l Coca-Cola pack",
"price": "50.00",
"qty":"5.00",
"amount":"250.00"
}],
"footer": {
"total":"1750.00",
"cash":"2000.00",
"balance":"250.00",
"notice": "In case of a price discrepancy, return the bill and item within 2 days to refund the difference."
},
}









share|improve this question





























    0















    I want to print a receipt with EPSON TM-T82.



    I am creating a restaurant app using given laravel API and ReactJS Front End. For the Bill or Invoice printing, I use jsPDF to print bill with thermal printer. jsPDF uses some paper sizes (A4, A3, legal ...). But there is not thermal printer paper which is 4 inch width and a roll of height.



    The print object will be given by an array/json. The sample bill format as follows.



    What I tried



    import React from 'react';
    import * as jsPDF from 'jspdf'

    class JSPDFTest extends React.Component
    {
    constructor(props)
    {
    super(props);
    this.printPDF = this.printPDF.bind(this);
    }

    printPDF()
    {
    var specialElementHandlers = {
    '#myId': function(element, renderer)
    {
    return true;
    },
    };

    var pdf = new jsPDF();

    pdf.text(10, 10, 'Hello World');

    pdf.save('Test.pdf');
    }

    render()
    {
    return (
    <div>
    <div id="myId">
    <h2> HTML to PDF</h2>
    <p> A sample HTML to PDF</p>
    </div>
    <button onClick = {this.printPDF}> Download PDF </button>
    </div>
    );
    }
    }

    export default JSPDFTest;


    Bill requirements




    • The header (Restaurant name, Address, Contact and Date/Time, Counter, Bill no) should be center alignment.

    • After the total items, horizontal separated should be there.

    • The text Net Total, CASH and Balance should be right alignment and those amounts in right alignment.

    • Finally notice should be printed with the title as above --- IMPORTANT NOTICE ---.


    Bill format



    |             ABC Restaurant            | }
    | Sunny Road, Canada | }
    | Contact : 123456789 | } // This is header should be centered
    | | }
    | 13/11/2018 12:45:49 SAKTHY No: 59 | }
    |---------------------------------------|
    | NO | ITEM | PRICE | QTY | AMOUNT |
    |:--:|:-------:|:------:|:---:|--------:| }
    | 1 The big tasty Pizza | }
    | ET4565 500.00 2.00 1000.00 | }
    | 2 Crunchy huge Buggers | } // Item name in first line others next line
    | BG8765 250.00 2.00 500.00 | } // PRICE and AMOUNT right aligned
    | 3 1.5 l Coca-Cola pack | }
    | CC9874 50.00 5.00 250.00 | }
    |---------------------------------------|
    | Net Total 1750.00 | }
    | | }
    | CASH 2000.00 | }
    | Balance 250.00 | }
    |-----------IMPORTANT NOTICE-----------| } // Footer monetary values right aligned
    | In case of a price discrepancy return | }
    | the bill and item within 2 day to | }
    | refund the difference | }


    Questions :




    • How to set random paper size, I read Aidiakapi here

    • Contents should be in the correct alignment (e.g: Prices right aligned).

    • One click to print


    Sample json or array



    {
    "header": {
    "invoice": "59",
    "name": "ABC Restaurant",
    "address": "Sunny Road, Canada",
    "contact": "123456789",
    "date": "13/11/2018 12:45:52",
    "counter": "SAKTHY"
    },
    "items": [{
    "no": "1",
    "item": "The big tasty Pizza",
    "price": "500.00",
    "qty":"2.00",
    "amount":"1000.00"
    },
    {
    "no": "2",
    "item": "Crunchy huge Buggers",
    "price": "250.00",
    "qty":"2.00",
    "amount":"500.00"
    },
    {
    "no": "3",
    "item": "1.5 l Coca-Cola pack",
    "price": "50.00",
    "qty":"5.00",
    "amount":"250.00"
    }],
    "footer": {
    "total":"1750.00",
    "cash":"2000.00",
    "balance":"250.00",
    "notice": "In case of a price discrepancy, return the bill and item within 2 days to refund the difference."
    },
    }









    share|improve this question



























      0












      0








      0








      I want to print a receipt with EPSON TM-T82.



      I am creating a restaurant app using given laravel API and ReactJS Front End. For the Bill or Invoice printing, I use jsPDF to print bill with thermal printer. jsPDF uses some paper sizes (A4, A3, legal ...). But there is not thermal printer paper which is 4 inch width and a roll of height.



      The print object will be given by an array/json. The sample bill format as follows.



      What I tried



      import React from 'react';
      import * as jsPDF from 'jspdf'

      class JSPDFTest extends React.Component
      {
      constructor(props)
      {
      super(props);
      this.printPDF = this.printPDF.bind(this);
      }

      printPDF()
      {
      var specialElementHandlers = {
      '#myId': function(element, renderer)
      {
      return true;
      },
      };

      var pdf = new jsPDF();

      pdf.text(10, 10, 'Hello World');

      pdf.save('Test.pdf');
      }

      render()
      {
      return (
      <div>
      <div id="myId">
      <h2> HTML to PDF</h2>
      <p> A sample HTML to PDF</p>
      </div>
      <button onClick = {this.printPDF}> Download PDF </button>
      </div>
      );
      }
      }

      export default JSPDFTest;


      Bill requirements




      • The header (Restaurant name, Address, Contact and Date/Time, Counter, Bill no) should be center alignment.

      • After the total items, horizontal separated should be there.

      • The text Net Total, CASH and Balance should be right alignment and those amounts in right alignment.

      • Finally notice should be printed with the title as above --- IMPORTANT NOTICE ---.


      Bill format



      |             ABC Restaurant            | }
      | Sunny Road, Canada | }
      | Contact : 123456789 | } // This is header should be centered
      | | }
      | 13/11/2018 12:45:49 SAKTHY No: 59 | }
      |---------------------------------------|
      | NO | ITEM | PRICE | QTY | AMOUNT |
      |:--:|:-------:|:------:|:---:|--------:| }
      | 1 The big tasty Pizza | }
      | ET4565 500.00 2.00 1000.00 | }
      | 2 Crunchy huge Buggers | } // Item name in first line others next line
      | BG8765 250.00 2.00 500.00 | } // PRICE and AMOUNT right aligned
      | 3 1.5 l Coca-Cola pack | }
      | CC9874 50.00 5.00 250.00 | }
      |---------------------------------------|
      | Net Total 1750.00 | }
      | | }
      | CASH 2000.00 | }
      | Balance 250.00 | }
      |-----------IMPORTANT NOTICE-----------| } // Footer monetary values right aligned
      | In case of a price discrepancy return | }
      | the bill and item within 2 day to | }
      | refund the difference | }


      Questions :




      • How to set random paper size, I read Aidiakapi here

      • Contents should be in the correct alignment (e.g: Prices right aligned).

      • One click to print


      Sample json or array



      {
      "header": {
      "invoice": "59",
      "name": "ABC Restaurant",
      "address": "Sunny Road, Canada",
      "contact": "123456789",
      "date": "13/11/2018 12:45:52",
      "counter": "SAKTHY"
      },
      "items": [{
      "no": "1",
      "item": "The big tasty Pizza",
      "price": "500.00",
      "qty":"2.00",
      "amount":"1000.00"
      },
      {
      "no": "2",
      "item": "Crunchy huge Buggers",
      "price": "250.00",
      "qty":"2.00",
      "amount":"500.00"
      },
      {
      "no": "3",
      "item": "1.5 l Coca-Cola pack",
      "price": "50.00",
      "qty":"5.00",
      "amount":"250.00"
      }],
      "footer": {
      "total":"1750.00",
      "cash":"2000.00",
      "balance":"250.00",
      "notice": "In case of a price discrepancy, return the bill and item within 2 days to refund the difference."
      },
      }









      share|improve this question
















      I want to print a receipt with EPSON TM-T82.



      I am creating a restaurant app using given laravel API and ReactJS Front End. For the Bill or Invoice printing, I use jsPDF to print bill with thermal printer. jsPDF uses some paper sizes (A4, A3, legal ...). But there is not thermal printer paper which is 4 inch width and a roll of height.



      The print object will be given by an array/json. The sample bill format as follows.



      What I tried



      import React from 'react';
      import * as jsPDF from 'jspdf'

      class JSPDFTest extends React.Component
      {
      constructor(props)
      {
      super(props);
      this.printPDF = this.printPDF.bind(this);
      }

      printPDF()
      {
      var specialElementHandlers = {
      '#myId': function(element, renderer)
      {
      return true;
      },
      };

      var pdf = new jsPDF();

      pdf.text(10, 10, 'Hello World');

      pdf.save('Test.pdf');
      }

      render()
      {
      return (
      <div>
      <div id="myId">
      <h2> HTML to PDF</h2>
      <p> A sample HTML to PDF</p>
      </div>
      <button onClick = {this.printPDF}> Download PDF </button>
      </div>
      );
      }
      }

      export default JSPDFTest;


      Bill requirements




      • The header (Restaurant name, Address, Contact and Date/Time, Counter, Bill no) should be center alignment.

      • After the total items, horizontal separated should be there.

      • The text Net Total, CASH and Balance should be right alignment and those amounts in right alignment.

      • Finally notice should be printed with the title as above --- IMPORTANT NOTICE ---.


      Bill format



      |             ABC Restaurant            | }
      | Sunny Road, Canada | }
      | Contact : 123456789 | } // This is header should be centered
      | | }
      | 13/11/2018 12:45:49 SAKTHY No: 59 | }
      |---------------------------------------|
      | NO | ITEM | PRICE | QTY | AMOUNT |
      |:--:|:-------:|:------:|:---:|--------:| }
      | 1 The big tasty Pizza | }
      | ET4565 500.00 2.00 1000.00 | }
      | 2 Crunchy huge Buggers | } // Item name in first line others next line
      | BG8765 250.00 2.00 500.00 | } // PRICE and AMOUNT right aligned
      | 3 1.5 l Coca-Cola pack | }
      | CC9874 50.00 5.00 250.00 | }
      |---------------------------------------|
      | Net Total 1750.00 | }
      | | }
      | CASH 2000.00 | }
      | Balance 250.00 | }
      |-----------IMPORTANT NOTICE-----------| } // Footer monetary values right aligned
      | In case of a price discrepancy return | }
      | the bill and item within 2 day to | }
      | refund the difference | }


      Questions :




      • How to set random paper size, I read Aidiakapi here

      • Contents should be in the correct alignment (e.g: Prices right aligned).

      • One click to print


      Sample json or array



      {
      "header": {
      "invoice": "59",
      "name": "ABC Restaurant",
      "address": "Sunny Road, Canada",
      "contact": "123456789",
      "date": "13/11/2018 12:45:52",
      "counter": "SAKTHY"
      },
      "items": [{
      "no": "1",
      "item": "The big tasty Pizza",
      "price": "500.00",
      "qty":"2.00",
      "amount":"1000.00"
      },
      {
      "no": "2",
      "item": "Crunchy huge Buggers",
      "price": "250.00",
      "qty":"2.00",
      "amount":"500.00"
      },
      {
      "no": "3",
      "item": "1.5 l Coca-Cola pack",
      "price": "50.00",
      "qty":"5.00",
      "amount":"250.00"
      }],
      "footer": {
      "total":"1750.00",
      "cash":"2000.00",
      "balance":"250.00",
      "notice": "In case of a price discrepancy, return the bill and item within 2 days to refund the difference."
      },
      }






      javascript jspdf billing pos






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 27 '18 at 5:44









      test team

      256




      256










      asked Nov 12 '18 at 19:29









      SAKTHYSAKTHY

      286




      286
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53268860%2freactjs-does-not-create-recipt-from-pos-printer%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53268860%2freactjs-does-not-create-recipt-from-pos-printer%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Florida Star v. B. J. F.

          Danny Elfman

          Lugert, Oklahoma