Code Monkey home page Code Monkey logo

zebra-zpl's People

Contributors

bbulpett avatar bulpettb avatar cassiomarques avatar dmytrovasin avatar eke-bb avatar lagtag avatar mtking2 avatar rafaelmf3 avatar tiagogeraldi avatar vkhalzov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zebra-zpl's Issues

sh: 1: rlpr: not found

Hi,

I was testing the code from "Printing the labels" but it gives me sh: 1: rlpr: not found error.

require_relative '/var/lib/gems/2.7.0/gems/zebra-zpl-1.1.4/lib/zebra/zpl'

label = Zebra::Zpl::Label.new(
    width:      200,
    length:     200,
    print_speed:3
)

barcode = Zebra::Zpl::Barcode.new(
    data:                       '12345678',
    position:                   [50, 50],
    height:                     50,
    print_human_readable_code:  true,
    narrow_bar_width:           4,
    wide_bar_width:             8,
    type:                       Zebra::Zpl::BarcodeType::CODE_128_AUTO
)

label << barcode

print_job = Zebra::PrintJob.new "my printer name in CUPS"

ip = "my-printer-ip" 

print_job.print label, ip

I'm not sure if the temp file with label is not creating and that's why this problem occurs. Could you help me?

Specs failing?

I'm on Ruby 2.5.1, I have these specs failing:

Run options: include {:focus=>true}

All examples were filtered out; ignoring {:focus=>true}

Randomized with seed 33892
................F.FF......F...FFFF.FF...FF.F.F.F.....FFFFFFFF....FFFF.F.F..F........FF.FF.F.......F.FFFFF...F........

Failures:

  1) Zebra::PrintJob raises an error if the printer does not exists
     Failure/Error:
       expect {
         described_class.new("Wrong")
       }.to raise_error(Zebra::PrintJob::UnknownPrinter)

     NameError:
       uninitialized constant Zebra::PrintJob::UnknownPrinter
     # ./spec/zebra/print_job_spec.rb:15:in `block (2 levels) in <top (required)>'

  2) Zebra::PrintJob#print prints the label
     Failure/Error:
       def print(label, ip)
         @remote_ip = ip
         tempfile = label.persist
         send_to_printer tempfile.path
       end

     ArgumentError:
       wrong number of arguments (given 1, expected 2)
     # ./lib/zebra/print_job.rb:17:in `print'
     # ./spec/zebra/print_job_spec.rb:33:in `block (3 levels) in <top (required)>'

  3) Zebra::PrintJob#print creates a cups print job with the correct arguments
     Failure/Error:
       def print(label, ip)
         @remote_ip = ip
         tempfile = label.persist
         send_to_printer tempfile.path
       end

     ArgumentError:
       wrong number of arguments (given 1, expected 2)
     # ./lib/zebra/print_job.rb:17:in `print'
     # ./spec/zebra/print_job_spec.rb:28:in `block (3 levels) in <top (required)>'

  4) Zebra::Zpl::Barcode can be initialized with the barcode type
     Failure/Error: type = Zebra::Zpl::BarcodeType::CODE_128_C

     NameError:
       uninitialized constant Zebra::Zpl::BarcodeType::CODE_128_C
       Did you mean?  Zebra::Zpl::BarcodeType::CODE_128_AUTO
     # ./spec/zebra/zpl/barcode_spec.rb:24:in `block (2 levels) in <top (required)>'

  5) Zebra::Zpl::Barcode#to_zpl contains the barcode type
     Failure/Error: tokens[3].should == Zebra::Zpl::BarcodeType::CODE_128_AUTO

       expected: "C"
            got: "N^FDfoobar^FS" (using ==)
     # ./spec/zebra/zpl/barcode_spec.rb:167:in `block (3 levels) in <top (required)>'

  6) Zebra::Zpl::Barcode#to_zpl contains the correct indication when the human readable code should be printed
     Failure/Error: tokens[7].should == "B"

       expected: "B"
            got: nil (using ==)
     # ./spec/zebra/zpl/barcode_spec.rb:184:in `block (3 levels) in <top (required)>'

  7) Zebra::Zpl::Barcode#to_zpl contains the X position
     Failure/Error: tokens[0].match(/B(\d+)/)[1].should == "100"

     NoMethodError:
       undefined method `[]' for nil:NilClass
     # ./spec/zebra/zpl/barcode_spec.rb:155:in `block (3 levels) in <top (required)>'

  8) Zebra::Zpl::Barcode#to_zpl contains the correct indication when the human readable code should not be printed
     Failure/Error: tokens[7].should == "N"

       expected: "N"
            got: nil (using ==)
     # ./spec/zebra/zpl/barcode_spec.rb:189:in `block (3 levels) in <top (required)>'

  9) Zebra::Zpl::Barcode#to_zpl begins with the command 'B'
     Failure/Error: barcode.to_zpl.should =~ /\AB/

       expected: /\AB/
            got: "^FWN^FO100,150^BY4^BCN,20,N^FDfoobar^FS" (using =~)
       Diff:
       @@ -1,2 +1,2 @@
       -/\AB/
       +"^FWN^FO100,150^BY4^BCN,20,N^FDfoobar^FS"
     # ./spec/zebra/zpl/barcode_spec.rb:151:in `block (3 levels) in <top (required)>'

  10) Zebra::Zpl::Barcode#to_zpl contains the data to be printed in the barcode
      Failure/Error: tokens[8].should == "\"foobar\""

        expected: "\"foobar\""
             got: nil (using ==)
      # ./spec/zebra/zpl/barcode_spec.rb:193:in `block (3 levels) in <top (required)>'

  11) Zebra::Zpl::Barcode#to_zpl contains the barcode wide bar width
      Failure/Error: tokens[5].should == "6"

        expected: "6"
             got: nil (using ==)
      # ./spec/zebra/zpl/barcode_spec.rb:175:in `block (3 levels) in <top (required)>'

  12) Zebra::Zpl::Barcode#to_zpl contains the barcode narrow bar width
      Failure/Error: tokens[4].should == "4"

        expected: "4"
             got: nil (using ==)
      # ./spec/zebra/zpl/barcode_spec.rb:171:in `block (3 levels) in <top (required)>'

  13) Zebra::Zpl::Barcode#to_zpl contains the Y position
      Failure/Error: tokens[1].should == "150"

        expected: "150"
             got: "150^BY4^BCN" (using ==)
      # ./spec/zebra/zpl/barcode_spec.rb:159:in `block (3 levels) in <top (required)>'

  14) Zebra::Zpl::Barcode#to_zpl contains the barcode height
      Failure/Error: tokens[6].should == "20"

        expected: "20"
             got: nil (using ==)
      # ./spec/zebra/zpl/barcode_spec.rb:179:in `block (3 levels) in <top (required)>'

  15) Zebra::Zpl::Barcode#to_zpl contains the barcode rotation
      Failure/Error: tokens[2].should == Zebra::Zpl::Rotation::NO_ROTATION.to_s

        expected: "N"
             got: "20" (using ==)
      # ./spec/zebra/zpl/barcode_spec.rb:163:in `block (3 levels) in <top (required)>'

  16) Zebra::Zpl::Box can be initialized with the end position
      Failure/Error: options.each_pair { |attribute, value| self.__send__ "#{attribute}=", value }

      NoMethodError:
        undefined method `end_position=' for #<Zebra::Zpl::Box:0x00007fd31e036c10>
        Did you mean?  position=
      # ./lib/zebra/zpl/printable.rb:14:in `block in initialize'
      # ./lib/zebra/zpl/printable.rb:14:in `each_pair'
      # ./lib/zebra/zpl/printable.rb:14:in `initialize'
      # ./spec/zebra/zpl/box_spec.rb:13:in `new'
      # ./spec/zebra/zpl/box_spec.rb:13:in `block (2 levels) in <top (required)>'

  17) Zebra::Zpl::Box#to_zpl raises an error if the end X position was not informed
      Failure/Error: options.each_pair { |attribute, value| self.__send__ "#{attribute}=", value }

      NoMethodError:
        undefined method `end_position=' for #<Zebra::Zpl::Box:0x00007fd31e034de8>
        Did you mean?  position=
      # ./lib/zebra/zpl/printable.rb:14:in `block in initialize'
      # ./lib/zebra/zpl/printable.rb:14:in `each_pair'
      # ./lib/zebra/zpl/printable.rb:14:in `initialize'
      # ./spec/zebra/zpl/box_spec.rb:43:in `new'
      # ./spec/zebra/zpl/box_spec.rb:43:in `block (3 levels) in <top (required)>'

  18) Zebra::Zpl::Box#to_zpl raises an error if the X position was not informed
      Failure/Error: options.each_pair { |attribute, value| self.__send__ "#{attribute}=", value }

      NoMethodError:
        undefined method `end_position=' for #<Zebra::Zpl::Box:0x00007fd31e032db8>
        Did you mean?  position=
      # ./lib/zebra/zpl/printable.rb:14:in `block in initialize'
      # ./lib/zebra/zpl/printable.rb:14:in `each_pair'
      # ./lib/zebra/zpl/printable.rb:14:in `initialize'
      # ./spec/zebra/zpl/box_spec.rb:29:in `new'
      # ./spec/zebra/zpl/box_spec.rb:29:in `block (3 levels) in <top (required)>'

  19) Zebra::Zpl::Box#to_zpl raises an error if the end Y position was not informed
      Failure/Error: options.each_pair { |attribute, value| self.__send__ "#{attribute}=", value }

      NoMethodError:
        undefined method `end_position=' for #<Zebra::Zpl::Box:0x00007fd31e030630>
        Did you mean?  position=
      # ./lib/zebra/zpl/printable.rb:14:in `block in initialize'
      # ./lib/zebra/zpl/printable.rb:14:in `each_pair'
      # ./lib/zebra/zpl/printable.rb:14:in `initialize'
      # ./spec/zebra/zpl/box_spec.rb:50:in `new'
      # ./spec/zebra/zpl/box_spec.rb:50:in `block (3 levels) in <top (required)>'

  20) Zebra::Zpl::Box#to_zpl contains the attributes in correct order
      Failure/Error: options.each_pair { |attribute, value| self.__send__ "#{attribute}=", value }

      NoMethodError:
        undefined method `end_position=' for #<Zebra::Zpl::Box:0x00007fd31e00a890>
        Did you mean?  position=
      # ./lib/zebra/zpl/printable.rb:14:in `block in initialize'
      # ./lib/zebra/zpl/printable.rb:14:in `each_pair'
      # ./lib/zebra/zpl/printable.rb:14:in `initialize'
      # ./spec/zebra/zpl/box_spec.rb:25:in `new'
      # ./spec/zebra/zpl/box_spec.rb:25:in `block (3 levels) in <top (required)>'
      # ./spec/zebra/zpl/box_spec.rb:68:in `block (3 levels) in <top (required)>'

  21) Zebra::Zpl::Box#to_zpl raises an error if the Y position was not informed
      Failure/Error: options.each_pair { |attribute, value| self.__send__ "#{attribute}=", value }

      NoMethodError:
        undefined method `end_position=' for #<Zebra::Zpl::Box:0x00007fd31e0083d8>
        Did you mean?  position=
      # ./lib/zebra/zpl/printable.rb:14:in `block in initialize'
      # ./lib/zebra/zpl/printable.rb:14:in `each_pair'
      # ./lib/zebra/zpl/printable.rb:14:in `initialize'
      # ./spec/zebra/zpl/box_spec.rb:36:in `new'
      # ./spec/zebra/zpl/box_spec.rb:36:in `block (3 levels) in <top (required)>'

  22) Zebra::Zpl::Box#to_zpl raises an error if the line thickness was not informed
      Failure/Error: options.each_pair { |attribute, value| self.__send__ "#{attribute}=", value }

      NoMethodError:
        undefined method `end_position=' for #<Zebra::Zpl::Box:0x00007fd31b0ee1d8>
        Did you mean?  position=
      # ./lib/zebra/zpl/printable.rb:14:in `block in initialize'
      # ./lib/zebra/zpl/printable.rb:14:in `each_pair'
      # ./lib/zebra/zpl/printable.rb:14:in `initialize'
      # ./spec/zebra/zpl/box_spec.rb:57:in `new'
      # ./spec/zebra/zpl/box_spec.rb:57:in `block (3 levels) in <top (required)>'

  23) Zebra::Zpl::Box#to_zpl begins with the 'X' command
      Failure/Error: options.each_pair { |attribute, value| self.__send__ "#{attribute}=", value }

      NoMethodError:
        undefined method `end_position=' for #<Zebra::Zpl::Box:0x00007fd31b0dfe08>
        Did you mean?  position=
      # ./lib/zebra/zpl/printable.rb:14:in `block in initialize'
      # ./lib/zebra/zpl/printable.rb:14:in `each_pair'
      # ./lib/zebra/zpl/printable.rb:14:in `initialize'
      # ./spec/zebra/zpl/box_spec.rb:25:in `new'
      # ./spec/zebra/zpl/box_spec.rb:25:in `block (3 levels) in <top (required)>'
      # ./spec/zebra/zpl/box_spec.rb:64:in `block (3 levels) in <top (required)>'

  24) Zebra::Zpl::Qrcode#to_zpl contains the data to be printed in the qrcode
      Failure/Error: tokens[5].should eq "\"foobar\""

        expected: "\"foobar\""
             got: "3^FDMA"

        (compared using ==)
      # ./spec/zebra/zpl/qrcode_spec.rb:98:in `block (3 levels) in <top (required)>'

  25) Zebra::Zpl::Qrcode#to_zpl contains QR code type
      Failure/Error: tokens[2].should eq "Q"

        expected: "Q"
             got: "2"

        (compared using ==)
      # ./spec/zebra/zpl/qrcode_spec.rb:86:in `block (3 levels) in <top (required)>'

  26) Zebra::Zpl::Qrcode#to_zpl begins with the command 'b'
      Failure/Error: qrcode.to_zpl.should =~ /\Ab/

        expected: /\Ab/
             got: "^FWN^FO50,50^BQN,2,3,,3^FDMA,foobar^FS" (using =~)
        Diff:
        @@ -1,2 +1,2 @@
        -/\Ab/
        +"^FWN^FO50,50^BQN,2,3,,3^FDMA,foobar^FS"
      # ./spec/zebra/zpl/qrcode_spec.rb:74:in `block (3 levels) in <top (required)>'

  27) Zebra::Zpl::Qrcode#to_zpl contains the Y position
      Failure/Error: tokens[1].should eq "50"

        expected: "50"
             got: "50^BQN"

        (compared using ==)
      # ./spec/zebra/zpl/qrcode_spec.rb:82:in `block (3 levels) in <top (required)>'

  28) Zebra::Zpl::Qrcode#to_zpl contains the scale factor
      Failure/Error: tokens[3].should eq "s3"

        expected: "s3"
             got: "3"

        (compared using ==)
      # ./spec/zebra/zpl/qrcode_spec.rb:90:in `block (3 levels) in <top (required)>'

  29) Zebra::Zpl::Qrcode#to_zpl contains the X position
      Failure/Error: tokens[0].match(/b(\d+)/)[1].should eq "50"

      NoMethodError:
        undefined method `[]' for nil:NilClass
      # ./spec/zebra/zpl/qrcode_spec.rb:78:in `block (3 levels) in <top (required)>'

  30) Zebra::Zpl::Qrcode#to_zpl contains the error correction level
      Failure/Error: tokens[4].should eq "eM"

        expected: "eM"
             got: ""

        (compared using ==)
      # ./spec/zebra/zpl/qrcode_spec.rb:94:in `block (3 levels) in <top (required)>'

  31) Zebra::Zpl::Text#to_zpl begins width the 'A' command
      Failure/Error: text.to_zpl.should =~ /\AA/

        expected: /\AA/
             got: "^FWN^CF0,28^CI28^FO100,150^FB,4,0,L,0^FDfoobar^FS" (using =~)
        Diff:
        @@ -1,2 +1,2 @@
        -/\AA/
        +"^FWN^CF0,28^CI28^FO100,150^FB,4,0,L,0^FDfoobar^FS"
      # ./spec/zebra/zpl/text_spec.rb:120:in `block (3 levels) in <top (required)>'

  32) Zebra::Zpl::Text#to_zpl assumes 1 as the default horizontal multipler
      Failure/Error: text.to_zpl.split(",")[4].to_i.should == Zebra::Zpl::HorizontalMultiplier::VALUE_1

        expected: 1
             got: 0 (using ==)
      # ./spec/zebra/zpl/text_spec.rb:124:in `block (3 levels) in <top (required)>'

  33) Zebra::Zpl::Text#to_zpl assumes the normal print mode as the default
      Failure/Error: text.to_zpl.split(",")[6].should == Zebra::Zpl::PrintMode::NORMAL

        expected: "N"
             got: "0^FDfoobar^FS" (using ==)
      # ./spec/zebra/zpl/text_spec.rb:132:in `block (3 levels) in <top (required)>'

  34) Zebra::Zpl::Text#to_zpl assumes no rotation by default
      Failure/Error: text.to_zpl.split(",")[2].to_i.should == Zebra::Zpl::Rotation::NO_ROTATION

        expected: "N"
             got: 150 (using ==)
      # ./spec/zebra/zpl/text_spec.rb:136:in `block (3 levels) in <top (required)>'

  35) Zebra::Zpl::Text#to_zpl assumes 1 as the default vertical multiplier
      Failure/Error: text.to_zpl.split(",")[5].to_i.should == Zebra::Zpl::VerticalMultiplier::VALUE_1

        expected: 1
             got: 0 (using ==)
      # ./spec/zebra/zpl/text_spec.rb:128:in `block (3 levels) in <top (required)>'

  36) Zebra::Zpl::Label#persisted? returns true if the `tempfile` attribute is not nil
      Failure/Error: label.instance_variable_set(:@tempfile, stub)

      ArgumentError:
        wrong number of arguments (given 0, expected 1..2)
      # ./spec/zebra/zpl/label_spec.rb:134:in `block (3 levels) in <top (required)>'

  37) Zebra::Zpl::Label#<< adds an item to the list of label elements
      Failure/Error: label << stub

      ArgumentError:
        wrong number of arguments (given 0, expected 1..2)
      # ./spec/zebra/zpl/label_spec.rb:60:in `block (4 levels) in <top (required)>'
      # ./spec/zebra/zpl/label_spec.rb:59:in `block (3 levels) in <top (required)>'

  38) Zebra::Zpl::Label#persist creates a tempfile
      Failure/Error: let(:tempfile) { stub.as_null_object }

      ArgumentError:
        wrong number of arguments (given 0, expected 1..2)
      # ./spec/zebra/zpl/label_spec.rb:103:in `block (3 levels) in <top (required)>'
      # ./spec/zebra/zpl/label_spec.rb:107:in `block (3 levels) in <top (required)>'

  39) Zebra::Zpl::Label#persist sets the `tempfile` attribute
      Failure/Error: let(:tempfile) { stub.as_null_object }

      ArgumentError:
        wrong number of arguments (given 0, expected 1..2)
      # ./spec/zebra/zpl/label_spec.rb:103:in `block (3 levels) in <top (required)>'
      # ./spec/zebra/zpl/label_spec.rb:107:in `block (3 levels) in <top (required)>'

  40) Zebra::Zpl::Label#persist returns the tempfile
      Failure/Error: let(:tempfile) { stub.as_null_object }

      ArgumentError:
        wrong number of arguments (given 0, expected 1..2)
      # ./spec/zebra/zpl/label_spec.rb:103:in `block (3 levels) in <top (required)>'
      # ./spec/zebra/zpl/label_spec.rb:107:in `block (3 levels) in <top (required)>'

  41) Zebra::Zpl::Label#dump_contents dumps its contents to the received IO
      Failure/Error: element.width = self.width

      NoMethodError:
        undefined method `width=' for {:to_zpl=>"foobar"}:Hash
      # ./lib/zebra/zpl/label.rb:39:in `<<'
      # ./spec/zebra/zpl/label_spec.rb:69:in `block (3 levels) in <top (required)>'

  42) Zebra::Zpl::Label#dump_contents does not try to set the length/gap when they were not informed (falls back to autosense)
      Failure/Error: io.should_not =~ /Q/

        expected not: =~ /Q/
                 got:    "^XA^LH0,0^LS10^PR2^PQ1^XZ"
        Diff:
        @@ -1,2 +1,2 @@
        -/Q/
        +"^XA^LH0,0^LS10^PR2^PQ1^XZ"
      # ./spec/zebra/zpl/label_spec.rb:86:in `block (3 levels) in <top (required)>'

3 deprecation warnings total

Finished in 0.0333 seconds (files took 0.1492 seconds to load)
117 examples, 42 failures

Failed examples:

rspec ./spec/zebra/print_job_spec.rb:12 # Zebra::PrintJob raises an error if the printer does not exists
rspec ./spec/zebra/print_job_spec.rb:31 # Zebra::PrintJob#print prints the label
rspec ./spec/zebra/print_job_spec.rb:27 # Zebra::PrintJob#print creates a cups print job with the correct arguments
rspec ./spec/zebra/zpl/barcode_spec.rb:23 # Zebra::Zpl::Barcode can be initialized with the barcode type
rspec ./spec/zebra/zpl/barcode_spec.rb:166 # Zebra::Zpl::Barcode#to_zpl contains the barcode type
rspec ./spec/zebra/zpl/barcode_spec.rb:182 # Zebra::Zpl::Barcode#to_zpl contains the correct indication when the human readable code should be printed
rspec ./spec/zebra/zpl/barcode_spec.rb:154 # Zebra::Zpl::Barcode#to_zpl contains the X position
rspec ./spec/zebra/zpl/barcode_spec.rb:187 # Zebra::Zpl::Barcode#to_zpl contains the correct indication when the human readable code should not be printed
rspec ./spec/zebra/zpl/barcode_spec.rb:150 # Zebra::Zpl::Barcode#to_zpl begins with the command 'B'
rspec ./spec/zebra/zpl/barcode_spec.rb:192 # Zebra::Zpl::Barcode#to_zpl contains the data to be printed in the barcode
rspec ./spec/zebra/zpl/barcode_spec.rb:174 # Zebra::Zpl::Barcode#to_zpl contains the barcode wide bar width
rspec ./spec/zebra/zpl/barcode_spec.rb:170 # Zebra::Zpl::Barcode#to_zpl contains the barcode narrow bar width
rspec ./spec/zebra/zpl/barcode_spec.rb:158 # Zebra::Zpl::Barcode#to_zpl contains the Y position
rspec ./spec/zebra/zpl/barcode_spec.rb:178 # Zebra::Zpl::Barcode#to_zpl contains the barcode height
rspec ./spec/zebra/zpl/barcode_spec.rb:162 # Zebra::Zpl::Barcode#to_zpl contains the barcode rotation
rspec ./spec/zebra/zpl/box_spec.rb:12 # Zebra::Zpl::Box can be initialized with the end position
rspec ./spec/zebra/zpl/box_spec.rb:42 # Zebra::Zpl::Box#to_zpl raises an error if the end X position was not informed
rspec ./spec/zebra/zpl/box_spec.rb:28 # Zebra::Zpl::Box#to_zpl raises an error if the X position was not informed
rspec ./spec/zebra/zpl/box_spec.rb:49 # Zebra::Zpl::Box#to_zpl raises an error if the end Y position was not informed
rspec ./spec/zebra/zpl/box_spec.rb:67 # Zebra::Zpl::Box#to_zpl contains the attributes in correct order
rspec ./spec/zebra/zpl/box_spec.rb:35 # Zebra::Zpl::Box#to_zpl raises an error if the Y position was not informed
rspec ./spec/zebra/zpl/box_spec.rb:56 # Zebra::Zpl::Box#to_zpl raises an error if the line thickness was not informed
rspec ./spec/zebra/zpl/box_spec.rb:63 # Zebra::Zpl::Box#to_zpl begins with the 'X' command
rspec ./spec/zebra/zpl/qrcode_spec.rb:97 # Zebra::Zpl::Qrcode#to_zpl contains the data to be printed in the qrcode
rspec ./spec/zebra/zpl/qrcode_spec.rb:85 # Zebra::Zpl::Qrcode#to_zpl contains QR code type
rspec ./spec/zebra/zpl/qrcode_spec.rb:73 # Zebra::Zpl::Qrcode#to_zpl begins with the command 'b'
rspec ./spec/zebra/zpl/qrcode_spec.rb:81 # Zebra::Zpl::Qrcode#to_zpl contains the Y position
rspec ./spec/zebra/zpl/qrcode_spec.rb:89 # Zebra::Zpl::Qrcode#to_zpl contains the scale factor
rspec ./spec/zebra/zpl/qrcode_spec.rb:77 # Zebra::Zpl::Qrcode#to_zpl contains the X position
rspec ./spec/zebra/zpl/qrcode_spec.rb:93 # Zebra::Zpl::Qrcode#to_zpl contains the error correction level
rspec ./spec/zebra/zpl/text_spec.rb:119 # Zebra::Zpl::Text#to_zpl begins width the 'A' command
rspec ./spec/zebra/zpl/text_spec.rb:123 # Zebra::Zpl::Text#to_zpl assumes 1 as the default horizontal multipler
rspec ./spec/zebra/zpl/text_spec.rb:131 # Zebra::Zpl::Text#to_zpl assumes the normal print mode as the default
rspec ./spec/zebra/zpl/text_spec.rb:135 # Zebra::Zpl::Text#to_zpl assumes no rotation by default
rspec ./spec/zebra/zpl/text_spec.rb:127 # Zebra::Zpl::Text#to_zpl assumes 1 as the default vertical multiplier
rspec ./spec/zebra/zpl/label_spec.rb:132 # Zebra::Zpl::Label#persisted? returns true if the `tempfile` attribute is not nil
rspec ./spec/zebra/zpl/label_spec.rb:58 # Zebra::Zpl::Label#<< adds an item to the list of label elements
rspec ./spec/zebra/zpl/label_spec.rb:111 # Zebra::Zpl::Label#persist creates a tempfile
rspec ./spec/zebra/zpl/label_spec.rb:120 # Zebra::Zpl::Label#persist sets the `tempfile` attribute
rspec ./spec/zebra/zpl/label_spec.rb:116 # Zebra::Zpl::Label#persist returns the tempfile
rspec ./spec/zebra/zpl/label_spec.rb:68 # Zebra::Zpl::Label#dump_contents dumps its contents to the received IO
rspec ./spec/zebra/zpl/label_spec.rb:84 # Zebra::Zpl::Label#dump_contents does not try to set the length/gap when they were not informed (falls back to autosense)

Randomized with seed 33892

printing from web app to printer on osx

I just setup a web app hosted on linux system. I connect the app with OSX client with a virtual zebra on localhost. When the print job is triggered, it fails :

  • with rlpr
rlpr: fatal error: client_open(): cannot connect to lpd
rlpr: error: connect to localhost:515: Connection refused
rlpr: warning: cannot bind to privileged port: lpd may reject
  • with lp nothing happens on the client, no failure on the server

When the app runs locally, lp printing completes successfully.
Am i missing something ?

Convert PNG to ZPL

It would be nice to be able to convert a PNG to a ZPL file. We have labels currently in PNG format and would like to easily print those on Zebra printers.

Add raw ZPL to label

Is there a possibility to add raw ZPL to a Zebra::Zpl::Label? I want to cache the zpl of an image to not recompile it every time. The image will always be on the same spot with the same attributes.

Thanks

Provide ZPL generation in a separate gem

Using Heroku, I am unable to deploy this as it relies on CUPS, which Heroku doesn't (and, really, oughtn't) have installed. The ZPL generation is what I need, and I send that generated code to a print service.

Having a "ZebraPrint" gem that requires a "ZpLGenerate" gem would be great, allowing for both the integration you need, but allow for the ZPL functionality to be used separately.

Field Block Hard Coded Attributes

The field block instruction has 5 values:

^FB maxWidth, maxLines, lineSpacing, alignment, hangingIndent

MaxLines, LineSpacing, and HangingIndent are all hard coded in the Text element. Need to add optional parameters for each of these (default to the current hard coded values to keep legacy code from breaking)

How to print caret(^) as text using zebra-zpl gem?

The following code:

label = Zebra::Zpl::Label.new print_speed: 6
label << Zebra::Zpl::Text.new(
  data: "Line 1",
  position: [100, 100],
  width: 400,
  font_size: Zebra::Zpl::FontSize::SIZE_2
)
label << Zebra::Zpl::Text.new(
  data: "Line 2: ^XZ^XAZ-1234", # This line should be escaped
  position: [100, 200],
  width: 400,
  font_size: Zebra::Zpl::FontSize::SIZE_2
)
io = StringIO.new
label.dump_contents(io)
puts io.string

generates the following text:

^XA^LH0,0^LS10^PR6
^FWN^CF0,22^CI28^FO100,100^FB400,4,,L,
^FDLine 1
^FWN^CF0,22^CI28^FO100,200^FB400,4,,L,
^FDLine 2: ^XZ^XAZ-1234^FS
^PQ1^XZ

but it should be:

^XA^LH0,0^LS10^PR6
^FWN^CF0,22^CI28^FO100,100^FB400,4,,L,
^FDLine 1
^FS^FWN^CF0,22^CI28^FO100,200^FB400,4,,L,
^FH^FDLine 2: _5EXZ_5EXAZ-1234
^PQ1^XZ

See ^FH Command in Zebra Programming Language (ZPL): https://stackoverflow.com/questions/16821629/how-to-print-a-tilde-in-zebra-programming-language-zpl)](https://www.zebra.com/content/dam/zebra_new_ia/en-us/manuals/printers/common/programming/zpl-zbi2-pm-en.pdf#page=189

Error While installing

Tested on Ubuntu 16.04 and 14.04

Error gem install zebra-zpl
$ gem install zebra-zpl
Building native extensions. This could take a while...
ERROR: Error installing zebra-zpl:
ERROR: Failed to build gem native extension.

current directory: /home/user/.gem/ruby/gems/cups-0.1.10/ext
/usr/bin/ruby -r ./siteconf20180131-41796-vda998.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/share/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /home/user/.gem/ruby/gems/cups-0.1.10 for inspection.
Results logged to /home/user/.gem/ruby/extensions/x86_64-linux/cups-0.1.10/gem_make.out
Error Bundle
$ bundle
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using bundler 1.16.0
Fetching cups 0.1.10
Installing cups 0.1.10 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: /home/user/.gem/ruby/gems/cups-0.1.10/ext
/usr/bin/ruby -r ./siteconf20180131-42078-w2pyzr.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/share/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /home/user/.gem/ruby/gems/cups-0.1.10 for inspection.
Results logged to /home/user/.gem/ruby/extensions/x86_64-linux/cups-0.1.10/gem_make.out

An error occurred while installing cups (0.1.10), and Bundler cannot continue.
Make sure that gem install cups -v '0.1.10' succeeds before bundling.

In Gemfile:
zebra-zpl was resolved to 1.0.2, which depends on
cups

Error While installing

Tested on Windows 10 & Centos 7

Error gem install zebra-zpl

$ gem install zebra-zpl
Building native extensions. This could take a while...
ERROR: Error installing zebra-zpl:
ERROR: Failed to build gem native extension.

current directory: /home/user/.gem/ruby/gems/cups-0.1.10/ext

/usr/bin/ruby -r ./siteconf20180131-41796-vda998.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/share/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /home/user/.gem/ruby/gems/cups-0.1.10 for inspection.
Results logged to /home/user/.gem/ruby/extensions/x86_64-linux/cups-0.1.10/gem_make.out

Error Bundle

$ bundle
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using bundler 1.16.0
Fetching cups 0.1.10
Installing cups 0.1.10 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: /home/user/.gem/ruby/gems/cups-0.1.10/ext

/usr/bin/ruby -r ./siteconf20180131-42078-w2pyzr.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/share/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /home/user/.gem/ruby/gems/cups-0.1.10 for inspection.
Results logged to /home/user/.gem/ruby/extensions/x86_64-linux/cups-0.1.10/gem_make.out

An error occurred while installing cups (0.1.10), and Bundler cannot continue.
Make sure that gem install cups -v '0.1.10' succeeds before bundling.

In Gemfile:
zebra-zpl was resolved to 1.0.2, which depends on
cups

Un-restrict Font Size

The ZPL II spec for the ^CF command allows font sizes (in dots) between 0 and 32000. Right now these are being restricted to 10 different sizes in font.rb:

def self.valid_font_size?(font_size)
  [12, 17, 22, 28, 33, 44, 67, 100, 111, 133].include?(font_size.to_i)
end

When setting the font_size attribute for Zebra::Zpl::Text, we should allow any number between 0 and 32000 as well as the 10 preset Zebra::Zpl::FontSize::SIZE_X we already have defined.

References

ZPL II Programming guide, page 139

Need better docs

Several features have been added like margins, etc. that are undocumented. Also some of the existing documentation will need to be refined. For instance, some updates have been made to allow additional arguments, etc.

I am not able to print PDF to 'Zebra ZP 450-200 dpi' printer. I am not getting any error in my rescue block.

file_name = "#{Rails.root}/app/assets/images/fedex_"+tracking_id.to_s+".pdf"
file = open(file_name)
base_image = Base64.encode64(file.read)
begin
label = Zebra::Zpl::Label.new(
width: 200,
length: 200,
print_speed: 3
)
pdf = Zebra::Zpl::PDF417.new(
data: base_image,
position: [100, 100]
)
label<<pdf
print_job = Zebra::PrintJob.new 'Zebra ZP 450-200 dpi'
ip = '127.0.0.1'
print_job.print label, ip, print_service: 'lp'

rescue Exception=>e
puts e.message
end

Add Graphics Elements

Aside from the Box, none of the built in graphics element are implemented yet.

  • Graphic circle - PR #31, #42
    ^GC diameter, thickness, color

  • Graphic diagonal line - PR #32, #42
    ^GD width, height, thickness, color, orientation

  • Graphic ellipse #42
    ^GE width, height, thickness, color

  • Graphic symbol #42
    ^GS orientation, height, width

  • Also the box element is already included, but does not have the corner rounding or color attributes included. Fixed by PR #33

  • Eventually it may be useful to add in a module for the related graphics values. Covered in #42

Element Width Overwritten by Overall Label Width

If an element specifies a width, it is overwritten when it's appended to the label.

label = Zebra::Zpl::Label.new(
        :width             => 800,
        :length            => 800,
        :print_speed       => 6,
        :print_density     => 5,
        :copies            => 1
      )

      label_fed_number = Zebra::Zpl::Text.new(
        :data              => ("FEDERAL RN#90630 ONT. REG.# 34333"),
        :position          => [0, 20],
        :justification     => Zebra::Zpl::Justification::LEFT,
        :font_size         => Zebra::Zpl::FontSize::SIZE_2,
        :width             => 200
      )
label << label_fed_number
label_fed_number.to_zpl
>>^FWN^CF0,22^CI28^FO0,20^FB200,4,0,L,0^FDFEDERAL RN#90630 ONT. REG.# 34333^FS
label.dump_contents
>> ^XA^LL800^LH0,0^LS10^PW800^PR6^FWN^CF0,22^CI28^FO0,20^FB800,4,0,L,0^FDFEDERAL RN#90630 ONT. REG.# 34333^FS^PQ1^XZ

At the moment, you can get around this bug by specifying a margin. However, this requires math and math is hard.

Release new RubyGems version

Similar to #38, but it looks like this gem has not been published to RubyGems since 1.0.2 back in April 2017.

Especially with some of the compatibility fixes in more recent versions, can you please publish the latest 1.0.5 release?

Memory Leak ?

Switch to 1.1.0 yesterday and seeing something which looks like a memory leak.

Back to b8ef53714f907349c2c93ac1627af13082e23af8 sounds to stop the leak from happening.

Screen Shot 2019-11-04 at 6 58 53 PM

Any ideas?

error on printing label

While on macOS issuing #print on Zebra::PrintJob instance with one argument (like stated in documentation) is throwing wrong argument number error, #print is expecting 2 arguments.
Quickly checking method's code revealed that ip of printers queue should be a second argument. However, #print with 2 arguments is also generating an error lp: No such file or directory, which in fact refers to code in private #method send_to_printer. Executing lp command without option -h #{@remote_ip} is sending temp file to the printer, executing with option -h #{@remote_ip} is returning error lp: No such file or directory. Is it just me or this private method #method send_to_printer needs a fix?

Code 37 Barcode options wrong.

Hi, the parameters for some of the barcodes, particularly Code 37, do not match the sequence generated by Zebra::ZPL::Barcode.to_zpl.

This is the default arguments in the code
^B#{type}#{rotation},,#{human_readable}^FD#{data}

But according to this manual )(Page 55 ^B3)
Screenshot 2021-09-07 at 13 04 57
There are two arguments before human_readable. Which means that currently you can't turn human_readable off.

I'm willing to try and provide a patch if you can offer some guidance in how you'd like it structured?

Thanks for the gem.

Wide Bar Width Support on Barcode Class (^BY)

Right now the wide_bar_width attribute is an attribute on the barcode model, but it is not used. Even worse, it's a required attribute.

See below for the BY command. Ideally we can support the ratio and the wide bar width. Also I don't believe any of these attributes need to be required.

Screen Shot 2019-10-31 at 2 53 14 PM

Add Support For PDF417 format.

pdf417_barcode_font
From the Zebra Docs

The ^B7 (PDF417) bar code instruction is a two-dimensional multirow,
continuous, stacked symbology. This bar code is capable of
encoding over 1000 bytes of data per label. It is ideally suited to
applications where large amounts of information are required at the
time the bar code is read.

The code consists of 3 to 90 stacked rows. Each row consists of
start/stop patterns and symbol characters called "codewords". A
"codeword" consists of 4 bars and 4 spaces. The minimum number of
"codewords"per row is 3.

This barcode is much different from the other supported barcodes, so it will need a separate class.

There are five specified attributes:

o = Orientation
Default value: Current ^FW value
(^FW defaults to N = Normal at power-up)
Other values:
N = Normal
R = Rotated, 90 degrees clockwise
I = Inverted, 180 degrees
B = Read from Bottom Up, 270 degrees

h = Bar Code Height for Individual Rows
(This number, multiplied by the module, equals the
height of the individual rows in dots.)
Default value: Value set by ^BY
Other values: 1 dot to height of label.
NOTE: 1 is not a recommended value.

s = Security Level
Determines the number of error detection and correction
code words to be generated for the symbol.
Default level provides only error detection (no correction).
Increasing the security level adds increasing
levels of error correction. (Increases symbol size.)
Default value: 0 = Error detection only
Other values: 1 to 8.
Error detection plus correction.

c = Number of Data Columns to Encode
User can specify number of codeword columns giving
control over the width of the symbol.
Default value: 1:2 row/column aspect ratio.
Other values: 1 to 30

r = Number of Rows to Encode
User can specify number of symbol rows giving control
over the height of the symbol.
Default value: 1:2 row/column aspect ratio.
Other values: 3 to 90
Example: With no row or column values entered, 72
codewords would be encoded into a symbol of 6 columns
and 12 rows. (Depending on codewords, aspect ratio
will not always be exact.)

t = Truncate Right Row Indicators and Stop Pattern
Default value: N = No truncation
Print right row indicators and stop pattern.
Other value: Y = Yes perform truncation.

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.