f



Print Zebra printer LP2824 USB from VB 5

Hi.

We have to develop a SW to print labels using a Zebra LP2824 printer,
which conects to the PC by USB. How may I send the ZPL commands to
print what I am supposed to? Is it possible to use fonts like Arial,
Times New Roman, etc?

Thx in advance.
0
bart2k (1)
9/7/2009 8:13:35 AM
comp.lang.basic.visual.misc 10153 articles. 0 followers. Post Follow

3 Replies
2874 Views

Similar Articles

[PageSpeed] 18

On 7 Sep, 09:13, Pepito Grillo <bar...@gmail.com> wrote:

> We have to develop a SW to print labels using a Zebra
> LP2824 printer, which conects to the PC by USB.

I don't use Label Printers myself but you should be able to use your
Zebra either by printing stuff to it in the normal way using the VB
Printer Object or alternatively by sending data (text, control codes,
etc, etc) directly to the printer. The former method probably severely
limits what you can do with Label Printers, but is very easy. The
latter method enables you to do anything that the printer is capable
of, but it requires an in depth knowledge of the various control codes
and/or language that your printer understands. I would imagine that
printers such as a Zebra Label Printer would come with various user
and programming manuals. Do you have these? If not then you should be
able to download them in pdf format from the Zebra website. I've just
had a quick look and I can see a few different manuals available at:

    http://www.zebra.com/id/zebra/na/en/index/resource_library/manuals.html

> Is it possible to use fonts like Arial,
> Times New Roman, etc?

As I've said, I've never actually used a Label Printer but I imagine
that if your requirements are limited and if you use the VB Printer
Object then Windows will allow you to use such fonts and will
rasterise them for you and send them to the printer as graphics.
However, for most real world tasks on a Label Printer I imagine you
will almost certainly need to address the Zebra directly instead of
using the VB Printer Object, in which case I'm sure there will be
details in one or other of the available manuals explaining how to use
such fonts. I've just downloaded and had a very quick look at some of
the Zebra LP2824 manuals and it would appear that it has five standard
built in fonts, all of which are mono spaced. It does however have the
capability of downloading TrueType fonts into its memory and there is
some ZebraDesigner Font Downloader software which I imagine will take
all the hard work out of that task for you and make it very easy. Once
you've uploaded the required TrueType fonts (Arial, Times New Roman or
whatever) to your Zebra printer then it should be able to use them and
print them very quickly. I imagine that you already have the
ZebraDesigner Font Downloader software, but if not then you should be
able to obtain it from Zebra, perhaps as a free download. I'm sure
there will be Zebra control codes that also enable you to perform such
a task anyway, but the Zebra software will obviously be the easier
option.

> How may I send the ZPL commands to print
> what I am supposed to?

You won't be able to use the standard VB Printer Object to do stuff
like that so you will need to bypass the standard Windows drivers and
instead send raw data direct to your printer, as in the following
example which can send raw data to any connected printer, including
USB connected printers. I've used a String in the example to contain
the data sent to the printer and you'll be able to include any
necessary control codes etc in the string, but you can easily amend it
to use a Byte Array instead if you prefer. As I've already said, I've
never actually used a Zebra printer or any other Label Printer and so
I don't offhand know what control codes it accepts or whether it
requires any initialisation string, so in the example I've just sent
some text followed by a standard FormFeed character. I don't know
whether the FormFeed character will work with your Zebra, or if it
will print the text in its default font without any other
initialisation codes, but if any part of it does not work then you
will be able to send it the appropriate Zebra Escape sequence instead
(either by building the required code bytes into a VB string or by
using a Byte array).

I'm afraid all this is mostly guesswork at the moment because I don't
have a suitable printer on which to try my code but it'll give you a
start. In fact I answered your question simply because I saw the word
"Zebra" in it and I remember quite some time ago answering some
questions about a Zebra printer (questions about page size or
printable area or precise positioning of printed elements or something
like that as far as I recall?). It was either on this newsgroup or on
the microsoft.public.vb.general.discussion group. I don't remember the
details now or whether there was anything in it that may also be of
interest to you, but it might be worth checking the archives (I can't
seem to see it at the moment myself). Anyway, here's the "direct to
printer" sample code. It should (hopefully) print "Hello World" and
eject the label on your Zebra, although you will be able to use the
same code to send anything you wish, including the various control
codes.

The code as it stands simply sends the data to whatever happens to
currently be your Windows default printer, so you will need to set the
Zebra as your default printer to try it. It will be very easy to amend
it though (if you wish to do so) in such a way that the code picks out
the Zebra whether it is your default printer or not. Paste the code
into a new VB project (one Form with a Command Button on it) and run
the project and click the button. Let me know if it works.

By the way, I use VB6 myself and I notice you are using VB5 but I
think the code should still work okay in VB5 because I haven't used
any VB6 specific stuff in it.

Mike

Option Explicit
Private Declare Function OpenPrinter Lib "winspool.drv" _
  Alias "OpenPrinterA" (ByVal pPrinterName As String, _
  phPrinter As Long, ByVal pDefault As Long) As Long
Private Declare Function StartDocPrinter Lib "winspool.drv" _
  Alias "StartDocPrinterA" (ByVal hPrinter As Long, _
  ByVal Level As Long, pDocInfo As DOCINFO) As Long
Private Declare Function StartPagePrinter Lib "winspool.drv" _
  (ByVal hPrinter As Long) As Long
Private Declare Function WritePrinter Lib "winspool.drv" _
  (ByVal hPrinter As Long, pBuf As Any, _
  ByVal cdBuf As Long, pcWritten As Long) As Long
Private Declare Function ClosePrinter Lib "winspool.drv" _
  (ByVal hPrinter As Long) As Long
Private Declare Function EndDocPrinter Lib "winspool.drv" _
  (ByVal hPrinter As Long) As Long
Private Declare Function EndPagePrinter Lib "winspool.drv" _
  (ByVal hPrinter As Long) As Long
Private Type DOCINFO
 pDocName As String
 pOutputFile As String
 pDatatype As String
End Type

Private Sub Command1_Click()
Dim myPrinter As Long, myDoc As Long, MyDocInfo As DOCINFO
Dim sWrite As String, charsWritten As Long, retVal As Long
retVal = OpenPrinter(Printer.DeviceName, myPrinter, 0)
If retVal = 0 Then
  MsgBox "Printer Not found"
Exit Sub
End If
MyDocInfo.pDocName = "Any Name"
MyDocInfo.pOutputFile = vbNullString
MyDocInfo.pDatatype = vbNullString
myDoc = StartDocPrinter(myPrinter, 1, MyDocInfo)
Call StartPagePrinter(myPrinter)
'
' send whatever you wish here
sWrite = "Hello World." & vbCrLf
retVal = WritePrinter(myPrinter, ByVal sWrite, _
    Len(sWrite), charsWritten)
'
sWrite = vbFormFeed
retVal = WritePrinter(myPrinter, ByVal sWrite, _
    Len(sWrite), charsWritten)
retVal = EndPagePrinter(myPrinter)
retVal = EndDocPrinter(myPrinter)
retVal = ClosePrinter(myPrinter)
End Sub


1
Mike
9/8/2009 7:30:34 AM
Pepito Grillo wrote:
> Hi.
> 
> We have to develop a SW to print labels using a Zebra LP2824 printer,
> which conects to the PC by USB. How may I send the ZPL commands to
> print what I am supposed to? Is it possible to use fonts like Arial,
> Times New Roman, etc?

Pepito, please regard this as utterly unreliable, just a guess. I don't 
know what ZPL means. It really needs an expert, not me :-) I have an HP 
printer, this works for me.

Option Explicit

Private Sub Form_Load()
Dim i As Long

    For i = 0 To Printers.Count - 1
       If InStr(Printers(i).DeviceName, "hp") Then
          Exit For
       End If
    Next i
    Set Printer = Printers(i)
    Printer.FontSize = 18
    Printer.Print "ABC*"
    Printer.EndDoc

End Sub

Regards

1
Martin
9/9/2009 5:27:47 PM
On 9 Sep, 18:27, Martin Trump <mar...@wmeadow.demon.co.uk> wrote:

> Pepito <snip> I have a HP printer, this works for me.
> <snip>
>     Printer.FontSize = 18
>     Printer.Print "ABC*"
>     Printer.EndDoc

Hi Martin. Nice to see you are still out and about. How's it going up
there in Trump Towers these days :-)

Your suggested code which uses the installed Windows printer drivers
for the Zebra (via the VB Printer Object) will almost certainly work
with the Zebra in much the same way as they work with your HP, and so
probably will many of the other various Printer Object methods (True
Type font selection, printer's bar code fonts, font size, text output,
line graphics, etc). In my own response I sort of skipped over those
functions (with just a brief mention of them) and I concentrated on
giving the OP code to allow him to use the alternative method of
bypassing the Zebra Windows printer driver and instead sending raw
data directly to the printer, since this will allow him to send it the
ZPL commands that he specifically asked for.

> I don't know what ZPL means <snip>

The ZPL to which the OP is referring is as far as I know is a small
proprietry language specifically designed for controlling Zebra label
printers. I've downloaded the printer manuals from the Zebra web page,
just out of interest, and they are for something called for EPL and
EPL2 (after a bit of Googling it appears that Zebra was at one point
in time called Eltron, hence the E instead of the Z). It's not really
a programming language, but more of a straightforward printer control
set, something similar to the Epson EscP and NEC and various other
printer control languages that became industry standards when the old
fashioned impact dot matrix printers were in common use. Essentially
you control the printer by sending it various control characters and
codes (what we used to call Escape sequences in the old days!). In
this way you can gain complete control over the printer and make it do
things that it would not be able to do using the VB Printer Object
methods. I don't have any experience of controlling Zebra printers or
other label printers of course, having never used one, but I imagine
it will be similar in many ways to the way that I used to drive my old
Citizen dot matrix printer about twenty five years ago!

Mike


0
Mike
9/9/2009 7:17:47 PM
Reply:

Similar Artilces:

VB 5/6 to visual studio basic express 2010
Hallo NG! Windows7/64/HP, OfficeXP/Pro/SP3, VB5EE/SP3, CPU AMD K10/3Ghz, 8GB Ram I have many programs written in vb5. Is there an easy way to import those into vsbe? Vy 73! Helge -- Helge, DJ1WM Helge Haensel wrote: > Hallo NG! > > Windows7/64/HP, OfficeXP/Pro/SP3, VB5EE/SP3, CPU AMD K10/3Ghz, 8GB Ram > I have many programs written in vb5. Is there an easy way to import those > into vsbe? > > Vy 73! Helge (This is probably better posted to microsoft.public.dotnet.languages.vb if your server carries it.) All of the VB.Net editions I've ...

Two USB printers on a USB print server
I have two USB printers, connected to the PC through a USB hub. I want to make the printers available to the other computers in the LAN, so I thought about buying a USB print server, and still use the hub. But I am concerned about the ability of a single-USB-port print server to deal with more than one USB device through the USB hub. I have the suspicion that not all the print servers handle this correctly. Do you know anything about which print servers are able to do what (if doable)? Thanks in advance _x. -- Only one "o" in my address. Xavier Llobet wrote: > I have ...

Vista Basic or Visual Basic conversation to VB.Net
Hello, I have a piece of code written in Vista Basic (similar to Visual Basic), and I'd like to know if you could help me find the equivalent in VB.NET? Here is the code: local lcopr as character store upper(this.value) to lcopr opentable("joprs") ordertable("joprs","joopr") seek("joprs", lcopr) store db.joprs.jodesc.value to thisform.textbox1.value store db.joprs.joextd.value to thisform.editbox1.value closetable("joprs") The code above is triggered when a user enters text into textboxA, which has a "CHANGE" trigger assigned ...

Can USB print server damage a USB printer
I ran into a strange problem with a Linksys PSUS4 USB print server. Its been connected to a Canon 6550 multifunction printer for months and suddenly it stopped working after someone tried to print to the Canon using the wrong printer driver. After going through the print servers admin utliity to check its status I found everything to be normal. It even claimed the printer was online and idle but when I would try to print it would fail. Even the Test Page sent from the print servers admin utility would fail. I tried resetting the printer server using the little reset button. Also unplug...

Visual Basic 5
Hello, I recently found one of my older cd's ' Visual Basic 5 Learning Edition ' I was playing aound with it a bit, when I noticed that the date was wrong. Date or Time, returns a date like 30/09/1899. What's wrong? 2Kbug? Are there any patches available? Thanks in advance. Kerbje. ...

Printing to only USB printer
I would like to be able to code my VB program to only print to my USB printer. Even though another tcp or lpt1 printer may be the default printer on the PC, I only want my VB app to print to the USB thermal printer. Dim Pr As Printer Dim myUSBPrinter As Printer For Each Pr In Printers If Instr ( Pr.Port, "USB001" ) > 0 Then ' Found a USB Printer Set myUSBPrinter = Pr Exit For End If Next Pr Pr always returns "nothing". It sees LPT1 and USB001 but will not set USB001 as my...

PRINTING ON USB PRINTER
HI, I HAVE MIGRATED FROM CLIPPER 5.3 TO xHARBOUR FEW DAYS BACK. I Converted all my codes to xharbour (it is 100% compatible), it is very fast, Can any body suggest me how to take print out to USB Printer from @......say command. i have tried "set printer to getdefaultprinter() " but it is not printing on usb printer. Thanks to Developers of Xharbour, You have given Life to clipper programmers. Anand Baid On 2 Ott, 14:19, anand <anandb...@gmail.com> wrote: > HI, > I HAVE MIGRATED FROM CLIPPER 5.3 TO xHARBOUR FEW DAYS BACK. > I Converted all my codes to xharbour (it...

How to print to a USB printer
Does anyone know how to print to a USB connected printer? I am using oorexx and windows vista os. I use SysWinGetDefaultPrinter() and it shows the printer port as USB001 I try to issue this command in my dialog "print \e:usb001:" ifile I receive message : unable to initialize device prn Do DOS commands work with USB connected devices? Tnaks This works under XP, have no vista to test it on (yet). One requirement is that a network must be active. So in case you don't have a network here are the complete instructions. 1) Install the Microsoft Loopback Adapter ...

Visual Basic 5
Has anyone managed to test Visual Basic version 5 in wine? I notice that there are results for earlier and later versions at winehq.org, but there are no resuts for Visual Basic version 5. Mark. -- Mark Hobley Linux User: #370818 http://markhobley.yi.org/ Mark Hobley <markhobley@hotpop.donottypethisbit.com> wrote: > Has anyone managed to test Visual Basic version 5 in wine? Runtime or the development environment? (VB Studio, IIRC, but it's been a very long time...) Chris Chris Davies <chris-usenet@roaima.co.uk> wrote: > Runtime or the developme...

Visual Basic 5
I have just upgraded from Win XP to Win7. Can I instal and run VB5 under Win7 ? John On Fri, 25 Apr 2014 16:21:57 +0800, John Mott <johnmott@iinet.net.au> wrote: >I have just upgraded from Win XP to Win7. >Can I instal and run VB5 under Win7 ? > Yes, but expect a few mild adventures. <g> -ralph On Fri, 25 Apr 2014 07:46:03 -0500, ralph <nt_consulting@yahoo.com> wrote: On second thought I might have posted more details on the possible "adventures" you might run into. However, exactly what problem/s you might run into, and how seriou...

Visual Basic 5
I pretend to save de contents of a TextBox and 3 Labels in a text file named: formula.txt in the directory: C:\Formulas Can you help me? Thanks "JMorais" <joaquim.morais.3@netvisao.pt> wrote in message news:newscache$ha1tih$7q3$1@newsfront4.netvisao.pt > I pretend to save de contents of a TextBox and 3 Labels in a text file > named: formula.txt in the directory: C:\Formulas f=freefile open "c:\formulas\formula.txt" for output as #f print #f,text1.text print #f,label1.caption print #f,label2.caption print #f,label3.caption close #f ...

QE 5.0 for PC: Have to log in as admin to print in colour Quark Express 5.0 for PC: Have to log in as admin to print in Quark Express 5.0 for PC: Have to log in as admin to print in colour
Using QE Passport on Win XP. When trying to print from a non admin user, the colour alternatives are greyed out and therefore not possible to choose. But, when logging in as admin I can print all colours. Any Suggestions why? Christian ...

Can somone help a Windows geek get a Mac to print to a USB printer on a print server???
I'm trying to help my sister and brother-in-law with their mixed marriage! They had a nice Windows home, pc's networked together and he decided he wanted to kill the home PC, get a MAC and have the two of them roam the house in cyber bliss. The problem is the printer - a HP PSC 2210 All-In-One. Since the desktop was PC was removed, I put in a D-Link DP-301U network USB print server. The Windows PC can print fine. The MacBook pro running OS X 10.4.11 can't. Despite the statements that MAS OS is supported all over the D-Link box, I can't get any support from D-Link. ...

FIX: HP 4000/4050 "41.5 Printer Error", printer printing blanks
Hello everyone Just posting this in the hope of making it easier for someone else down the line - we have an HP LaserJet 4050 that suddenly started throwing a 41.5 Printer Error and printing blanks. The fix turned out to be very easy but if I hadn't figured it out it may have resulted in an expensive service call. My separation roller - the blue & grey roller in the paper tray - had moved out of place. I just pushed it back in place and it was fixed. Here's a page that has pictures of the separation and feed rollers on a 4000 series printer. The separation roller is part of the...

Web resources about - Print Zebra printer LP2824 USB from VB 5 - comp.lang.basic.visual.misc

Printer's key - Wikipedia, the free encyclopedia
The printer’s key , also known as the number line , is a line of text printed on the copyright page (the verso of the title page ) of books, ...

Loving the new job. Fleet master for 30 printers(strong possib... - Facebook
Facebook is a social utility that connects people with friends and others who work, study and live around them. People use Facebook to keep ...

IC3D Printers (@IC3D_Printers) on Twitter
Sign in Sign up You are on Twitter Mobile because you are using an old version of Internet Explorer. Learn more here IC3D Printers @ IC3D_Printers ...

Thread: Are there any wireless laser printers that work?
I got a Brother printer a few years back on the recommendation of a friend, and it's been a wonderful printer. Fast and trouble-free. As someone ...

App Store - EPSON Printer Finder
Get EPSON Printer Finder on the App Store. See screenshots and ratings, and read customer reviews.

Make Magazine 3D Printer Workshop - a set on Flickr
Working on 3D printer testing for the MAKE Ultimate Guide to 3D Printing due out this fall. Day 1, unedited, unofficial photos.

The 3D printer carving out a new curriculum
With Australia's technical expertise slowly whittling away, the team behind this gadget wants to take schools back to the basics of manufacturing ...

ASIC investigating company after inventor of world's largest 3D printer left out of pocket
... Australian Securities and Investments Commission investigates the administration of a company that tried to sell the world's largest 3D printer. ...

9to5Toys Lunch Break: Brother Laser Printer $45, 9′ MFi Lightning Cable $6, iPhone 6/s Plus Leather Folio ...
... Twitter , RSS Feed , Facebook , Google+ and Safari push notifications . TODAY’S CAN’T MISS DEALS: Daily Deals: Brother Monochrome Laser Printer ...

Doro PDF printer adds color conversion, page rotation controls
Lightweight virtual PDF printer Doro has been updated with new color conversion and page rotation settings. If the default "UseDeviceIndependentColor" ...

Resources last updated: 2/8/2016 1:08:13 PM