Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

EasyPost/example-print-label

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

EasyPost Label Printing Example

The EasyPost API provides an easy way to programatically create shipments and postage labels. This project demonstrates combining the EasyPost APIs with PrintNode to easily print out any labels generated with your EasyPost account.

The application provides a minimal web application that can be hosted on any computer, and will remotely send ZPL labels to any PrintNode enabled printer.

Requirements

  1. A Windows or Mac computer running Ruby Bundler (it must be able to run the PrintNode client)
  2. Some type of printer that supports ZPL files (we used a Zebra ZP450)
  3. An EasyPost account
  4. A PrintNode account

Printer Setup

PrintNode has clear documentation on getting your printer set up so if you encounter any issues, refer there for more details.

  1. Download and install the PrintNode client
  2. Plug in your printer
  3. On OSX we manually added our printer with the below steps:
    1. Open a terminal and run lpinfo -v | grep usb to find your plugged in printer. It should return a line that looks something like: direct usb://Zebra%20Technologies/ZTC%20ZP%20450-200dpi?serial=XXXXXXXXXXXX
    2. Run lpadmin -p raw_zebra -E -v usb://Zebra%20Technologies/ZTC%20ZP%20450-200dpi?serial=XXXXXXXXXXXX in your terminal to install the printer with the name raw_zebra. You will need to replace the usb://Zebra%20Technologies/ZTC%20ZP%20450-200dpi?serial=XXXXXXXXXXXX with what the previous command returned for you.
    3. Once this is all set, you should see a new entry on your PrintNode Printers list

Running the Application

  1. Check out this repo and cd into the project directory
  2. Copy or rename the sample.env to .env, and fill in values for
    1. your EasyPost Api Key
    2. your PrintNode API Key
    3. your printer's PrintNode Id
  3. Run bundle install
  4. Run rackup
  5. The application should be up and running at http://localhost:9292/

Troubleshooting

Occasionally, our printer would be showing up on PrintNode, but would fail to print files. In these situations, a quick power cycle of the printer took care of any issue.

If you still run into problems, you can try removing your printer and re-adding it. If you're on OSX and followed the instructions above, just run lpadmin -x raw_zebra to remove the printer.

If you aren't seeing any labels, make sure you have bought some postage on EasyPost! You can walk through the EasyPost Getting Started Guide using your test API Key and you won't be charged.

About

Sample integration between EasyPost and PrintNode

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published