Skip to content

Instantly share code, notes, and snippets.

@SethWilson
Created May 2, 2017 17:27
Show Gist options
  • Save SethWilson/e3d7609f6b95614f66eaea228b49bd84 to your computer and use it in GitHub Desktop.
Save SethWilson/e3d7609f6b95614f66eaea228b49bd84 to your computer and use it in GitHub Desktop.
require 'uri'
require 'net/http'
require 'net/https'
zpl = ARGF.read
uri = URI.parse( 'http://api.labelary.com/v1/printers/8dpmm/labels/4x6/0/' )
https = Net::HTTP.new(uri.host,uri.port)
https.use_ssl = false
req = Net::HTTP::Post.new(uri.path, initheader = {'Accept' =>'image/png'})
req.body = zpl
puts "Requestiong"
res = https.request(req)
case res
when Net::HTTPSuccess then
puts "Success"
File.open "/tmp/zpl.png", 'wb' do |f| # change file name for PNG images
f.write res.body
end
`qlmanage -p /tmp/zpl.png `
else
puts "Error: #{res.body}"
end
@SethWilson
Copy link
Author

An Automator script that will create a png of any selected ZPL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment