Code Monkey home page Code Monkey logo

escpos's Issues

concatenating helpers?

hi,

thank you for your effort in putting this great implementation together.

do you have any advice for concatenating helper methods?
for example, applying 'big' and 'center' to a string simultaneously.

thank you,
spencer

wrong example codes

[29] pry(main)> @printer = Escpos::Printer.new
=> #<Escpos::Printer:0x00007efc2e1bbd78 @data="\e@">
[30] pry(main)> @printer << "Some text"
=> "\e@Some text"
[31] pry(main)> @printer << Escpos::Helpers.big("Big text")
NoMethodError: undefined method `big' for Escpos::Helpers:Module

even had to wrap big call in brackets, otherwise syntax error.

Ruby 3.2

Helper methods not available

Hi,

First of all thank you for your work.
I have a problem with helpers, if I try to use them I always get for instance "NoMethodError (undefined method `center'").

this is my report class:

class MerchantInfo < Escpos::Report

  def cfe_data
    options[:cfe_data]
  end

  def merchant_title text
    center "#{text}"
  end

  def self.create_merchant_info
    layout_dir = Rails.root.join('app/views/api/v1/thermal_cfe/merchant_info.erb').to_s
    cfe_layout = MerchantInfo.new(layout_dir,
                                  {
                                      cfe_data:Hash(merchant:COMMERCES[0])
                                  }
    )
    puts "cfe_layout #{cfe_layout.to_json}"
    cfe_layout
  end
end

this is my view file:
#merchant_info.erb

<%=merchant_title cfe_data[:merchant]%>

ruby version 2.5.3
rails version 5.2.1

Thank you in advance for your help.

Chinese scrambled code

Hi , I use @printer.to_escpos the Chinese but show my scrambled code. how can i solve it。thanks for your help

Set UTF-8 LATIN1 encoding

How I set th encoding to work on LATIN1 on CP_CP858

I trying to

text = Escpos::Printer.new
text << Escpos::Helpers.set_printer_encoding(Escpos::CP_CP858)
text << Escpos::Helpers.encode(ptr_text, encoding: "CP-858")

but I having the error code converter not found (UTF-8 to CP-858)

how I use this code table?

Can't make it work on Debian

Hello,
I have everything setup as said in the documentation but have nothing when I try. Is there anything else to install or configure?

not well documented, need clarification

Docs not giving actual example but using hard coded data like for some static report

<%= item "First item" %>
<%= item "Second item" %>
<%= item "Third item" %>

There should have been some actual object like an order with items etc.

Now how to pass an object report.erb from
report = MyReport.new 'path/to/my_report.erb'

than using multiple styles, its just showing quad_text
& exactly at which point it sends data to printer

Is it possible to use ActionView::Helpers inside Escpos::Report?

Hi, I'm trying to build a feature using the Escpos::Report.

But when I try to use ActionView::Helpers (already included in the Report Class), it throws a weird error:

#<NoMethodError: undefined method `in_rendering_context' for <EscPosServices::Reports::Invoice:0x00007f849e226af8>>

I leave an example:

# invoice.rb
class EscPosServices::Reports::Invoice < Escpos::Report
  include ActionView::Helpers

  def sale
    options[:sale]
  end

  def current_tenant
    options[:current_tenant]
  end
end
<%= right(bold("Subtotal: ") + number_to_currency(sale.subtotal)) %>
<%= right(bold("Descuento: ") + number_to_currency(sale.discount_amount)) %>

Versions:
Rails 6.0.3.7
Escpos gem 0.0.10
Ruby 2.7.3

Printer compatibility

This looks like a brilliant gem. Could you confirm which printers you know work with this?

I've tried your sample code with my Brother TD-4000 but so far it's stubbornly silent.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.