Code Monkey home page Code Monkey logo

rdpl's Introduction

rdpl

Rdpl is a simple gem that abstracts some of the DPL (Datamax Programming Language)(TM) concepts. Its main purpose is to simplify the creation of labels to be printed using the Datamax(TM) series of printers.

It uses a very simple approach to send jobs to the printer. Basically, the printer has to be configured inside CUPS (Rdpl will use lpr to print), so it won’t work on systems where CUPS is absent.

Jobs

Print jobs are represented through instances of Rdpl::Job. A job may contain several labels to be printed and must receive the printer’s cups id.

job = Rdpl::Job.new :printer => "some_printer_id"
job.print

Take a look at the project’s rdoc for available options.

Labels

Labels are represented through instances of Rdpl::Label. A label may contain several elements, which may be text, barcodes, lines, boxes or other graphical elements.

job = Rdpl::Job.new :printer => "some_printer_id"
label = Rdpl::Label.new(:quantity => 3, :dot_size => 12)
label << "some text"
label << Rdpl::Barcode.new :data => "123456"
job << label
job.print

Labels also accept a block when adding new lines, barcodes, boxes or bitmapped text:

label = Label.new
label.add_line do |line|
  line.horizontal_width = 12.2
  line.vertical_width   = 14.3
  line.row_position     = 23.4
  line.column_position  = 24.5
end

It’ll always yield a new instance of the given element to the block, so you can specify the element’s properties. The other available methods to add new elements to the label are add_barcode, add_box and add_bitmapped_text.

All labels must be closed before printing, so the printer knows where the printing must end and where another label is started.

label.end!

Take a look at the project’s rdoc for available options.

Elements

You can add elements to the labels. Elements may be text, barcodes, lines, boxes or text printed with internal bitmapped fonts. Elements may have a rotation angle, row and column positions and so on. Each kind of element may have specific options, check the docs.

Barcodes

Barcodes may be created through the Rdpl::Element::Barcode class.

barcode = Rdpl::Barcode.new(
  :rotation              => 4,
  :font_id               => Rdpl::Barcode::CODE_128,
  :data                  => 'SOME DATA 12345',
  :height                => 123,
  :wide_bar_multiplier   => 3,
  :narrow_bar_multiplier => 4,
  :row_position          => 123,
  :column_position       => 234
)

Take a look at the project’s rdoc for available options.

Boxes

Boxes may be created through the Rdpl::Element::Box class.

box = Rdpl::Box.new(
  :horizontal_width         => 12.2,
  :vertical_width           => 14.3,
  :row_position             => 23.4,
  :column_position          => 24.5,
  :bottom_and_top_thickness => 34.6,
  :sides_thickness          => 45.6
)

Take a look at the project’s rdoc for available options.

Lines

Lines may be created through the Rdpl::Element::Line class.

line = Rdpl::Line.new(
  :horizontal_width => 12.2,
  :vertical_width   => 14.3,
  :row_position     => 23.4,
  :column_position  => 24.5
)

Take a look at the project’s rdoc for available options.

Text in Bitmapped fonts

Text elements printed using internal bitmapped fonts may be created through the Rdpl::Element::BitmappedText class.

text = Rdpl::BitmappedText.new(
  :font_id           => 2,
  :width_multiplier  => 2,
  :height_multiplier => 3,
  :row_position      => 20,
  :column_position   => 30,
  :data              => 'HEY LOOK AT ME'
)

Take a look at the project’s rdoc for available options.

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2010 Cássio Marques. See LICENSE for details.

rdpl's People

Contributors

cassiomarques avatar

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.