LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-20-2011, 04:08 PM   #1
DiBosco
Member
 
Registered: Nov 2001
Location: Manchester, UK
Distribution: Mageia
Posts: 807

Rep: Reputation: 40
Accessing a [Ethernet] printer in Linux


Folks,

I need to send a file I will create to a [barcode] printer. It's very simple, just a few lines of .xml type ASCII and apparently if the printer receives this it will print out my barcode.

Now, there are cups drivers for these [Zebra] printers and apparently, when installing the printer you just set it up in Linux as a zpl or epl Zebra device and the OS will find it.

Now, what I am unclear about is how to actually get this file to the printer. My gut feeling is I could open a connection to the file which I would expect to see in /dev, but I have an HP Laserjet 5000 that I use and I can't see anything that is obviously it in /dev.

I've developed my app in Qt and just need to write some code to create the .zpl file and then work out how to get it from my app to the printer itself. Would anyone be able to advise on how I can do this please? I don't actually have the printer yet, but would like to have as much code ready as possible for when it arrives.

Many thanks.
 
Old 09-20-2011, 04:12 PM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
If you're using C/C++, you'll want to be looking at the CUPS API. I'm afraid I haven't used it personally so I can't provide any personal insight into its use...

Hope this helps,
 
Old 09-20-2011, 05:12 PM   #3
DiBosco
Member
 
Registered: Nov 2001
Location: Manchester, UK
Distribution: Mageia
Posts: 807

Original Poster
Rep: Reputation: 40
Thanks, that does look like it's what I'll need. Lots of pointers to pointers. There's something new for me to learn! They seem to have some basic examples of how to use the API calls, not entirely sure about how some of it works at first glance, but hopefully that will get me started.
 
Old 09-20-2011, 05:19 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,680

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
Although none of the links work there is also a user guide on the page that might provide some help.
https://km.zebra.com/kb/index?page=c...7680&actp=LIST

In general, I would setup the printer with a static IP address. Next add the printer via the cups web interface (i.e. localhost:631). The URL of the printer will be IP_address:9100. There will also be a step to select the printer driver.

To print a file via the command line:
lpr -P zebra filename

Replace zebra with the actual printer name that was used when you added the printer.

You can also view the setup for the HP from the cups web interface.
 
Old 09-20-2011, 05:25 PM   #5
DiBosco
Member
 
Registered: Nov 2001
Location: Manchester, UK
Distribution: Mageia
Posts: 807

Original Poster
Rep: Reputation: 40
Thanks, Michael, that's also helpful. I'd already seen, and got frustrated by, the broken links on the Zebra site.

There's a lot of useful example programs on the cups site, I'm just having a go at listing the printers on my system from a simple Qt app I'm knocking up.
 
Old 09-20-2011, 06:09 PM   #6
DiBosco
Member
 
Registered: Nov 2001
Location: Manchester, UK
Distribution: Mageia
Posts: 807

Original Poster
Rep: Reputation: 40
Looks straighforward, this lists my CUPS printers:

Code:
int MainWindow::listPrinters(void)
{
  int i;
  cups_dest_t *dests, *dest;
  int num_dests = cupsGetDests(&dests);

  for (i = num_dests, dest = dests; i > 0; i --, dest ++)
  {

      ui->textEdit->append(QString::QString(dest->name) + "\n");
    if (dest->instance)
      printf("%s/%s\n", dest->name, dest->instance);
    else
      puts(dest->name);
  }

  return (0);
}
That's just slightly modifying some example code in the link Snark gave me.

Also, once I knew what to search for a bit better thanks to Snark, this also helped a lot. It specifically deals with sending text to the Zebra printers which is exactly what I want. It's amazing how all the sales people in the distributors when you first ask them say you can't use Zebra printers from Linux.

Hope this also helps someone in future.

Last edited by DiBosco; 09-20-2011 at 06:10 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing windows share printer into linux kuddush Linux - Desktop 1 03-18-2011 01:30 AM
printing problem on linux pc while accessing printer which is set on windows pc pankajd Linux - Software 1 11-11-2008 08:59 PM
accessing windows printer through mepis linux acbl MEPIS 1 08-15-2006 10:25 AM
Accessing a printer on a windows XP machine from my Linux box drebbin Linux - Newbie 2 09-20-2004 02:39 PM
Accessing windows printer through linux hariiyer Linux - Networking 1 08-08-2004 10:15 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration