|
You have to make sure that you have the font for the BarCode text in your fonts folder in the windows folder.
|
|
|
|
|
Hi,
Hoping you help, when I run your code, thanks by the way, I am getting an unhandled handle, vs2005 says that the line = New FileStream(hPortP, FileAccess.Write) is deprecated and a safehandle should be used could you please explain?
Thanks
|
|
|
|
|
Reference:
Imports Microsoft.Win32.SafeHandles
Declare:
Dim handle As SafeFileHandle
In your sub:
'Get unsafe pointer
'hPortP = New IntPtr(_hPort) 'convert Integer to IntPtr
handle = New SafeFileHandle(New IntPtr(_hPort), True) 'Convert to safefilehandle
'Create file stream
_outFile = New FileStream(handle, access)
|
|
|
|
|
Hello and thank you for making it easy for others to use it.
Just one query,
Using vs 2008 for development, and is trying to use the code that you have mentioned.
Dim Texxxt As String
Dim SA As SECURITY_ATTRIBUTES
Dim handle As SafeFileHandle
Dim outFile As FileStream, hPortP As IntPtr
LPTPORT = "USB002"
Texxxt = Me.RichTextBox1.Text
hPort = CreateFile(LPTPORT, GENERIC_WRITE, FILE_SHARE_WRITE, SA, OPEN_EXISTING, 0, 0)
handle = New SafeFileHandle(New IntPtr(hPort), True)
' hPortP = New IntPtr(hPort) 'convert Integer to IntPtr
outFile = New FileStream(handle, FileAccess.Write) 'Create FileStream using Handle
Dim fileWriter As New StreamWriter(outFile)
fileWriter.WriteLine(" ")
fileWriter.WriteLine("N")
fileWriter.Write("A50,50,0,4,1,1,N,")
fileWriter.Write(Chr(34))
fileWriter.Write("Zebra")
fileWriter.Write(Chr(34))
fileWriter.Write(Chr(13))
fileWriter.Write(Chr(10))
fileWriter.Write("A50,100,0,4,1,1,N,")
fileWriter.Write(Chr(34))
fileWriter.Write("Tech Support")
fileWriter.Write(Chr(34))
fileWriter.Write(Chr(13))
fileWriter.Write(Chr(10))
fileWriter.WriteLine("P1")
fileWriter.Flush()
fileWriter.Close()
outFile.Close()
retval = CloseHandle(hPort)
End Sub
That is the code that i am trying to use, inorder to print my barcodes to a zebra TPL 2844 printer connected to my USB port.
The value of hport is coming -1 , that means nothing is being assigned to it, that's what i think.
Getting the same error, argumentexception, invalid handler.
Please reply to this as soon as possible for you..
Regards
|
|
|
|
|
i have the same problem any solution?
|
|
|
|
|
Hi, i this code is awesom it helped me a lot. Thx for publixhing it
But, i still can't get round an issue here, u see, i need to write multiple lines (up to 4) on the label and then a barcode with human readeable data.
What happens is that if i send a string like "hello\r\nJuanhello\r\nJuanhello\r\nJuan" to 1 command it writes it all in the same line and the letters overlap.
So i send 1 command per word, that helped, but what actually happens it that it now writes the last word only (Juan)
I'm thinking there might be a problem with the dimensions the printer gets to write the lines, like, is printing it all but not on the label...
i really ran outta ideas of how to fix this, and i cannot se nowhere in the code where the label's dimensions concerning the text only are, since the bar code prints perfectly
I'll be waiting for anything u can throw at me. thx
btw: i'm writing this in c# .net!
Thx!!
|
|
|
|
|
This would be a reply to myself...
Accostumed to work with wordprocessors and all, the thing is that i forgot
that i was passing the same coordinates to every single line i wrote, therefore
all lines were going to overlap!
my bad!
|
|
|
|
|
Great example and greatly appreciate the work. Can someone help with adding in variable and how to use what template? Basically I am working in VB.NET 2005 in creating a small application that pulls data from a SQL database and than print it to the label.
I was able to take the Zebra design label software to create a template call templabel.lbl with some variable. How would I specify so that ID textfield is tied to variable ID and so on?
|
|
|
|
|
Did you get an answer? If not, let me know I'll send you some code.
YOU MUST read the EPL2 manual to lookup the rules:
There is a section in there with an example.
Here is a sample EPL2 template:
There are bascally 4 sections.
1)initialization commands
2)Variables section
3)Others(anything else, captions , line etc...)
4) the variables data values section(this is the one that will get you!)
The number of variables must be equal to the number of of values lines or else...
You can use the same
REMOVE THIS LINE[ SECTION 1]:
O
D8
S2
ZT
JF
I8,0
OD
REMOVE THIS LINE[ SECTION 2]:
FK"FORMNAME"
FS"FORMNAME"
V00,40,N,""
V01,40,N,""
V02,25,N,""
Q812,24
q812
REMOVE THIS LINE[ SECTION 3]:
A37,12,0,2,2,2,N,"CAT's NAME:"
A405,43,0,3,1,1,N,"CAT'S WEIGHT:"
A75,139,0,3,1,1,N,V00
A227,938,0,3,1,1,N,V01
A392,558,0,4,1,1,N,V02
FE
FR"GEReturn"
REMOVE THIS LINE[ SECTION 4]:
?
V000DATAVALUE
V001DATAVALUE
V002DATAVALUE
REMOVE THIS LINE[ P1 = print 1 page P2 means print pages and so on.]:
P1
FK"FORMNAME"
REMOVE THIS LINE[ in FK"FORMNAME" the name quotes MUST be 8 chars or less]
I hope this helps
|
|
|
|
|
Are you using the free version?
|
|
|
|
|
i was getting the same exception error, which was due to the CreateFile function returning a -1. This seemed to be caused by a bad lpFileName parameter (the first argument for the CreateFile function) So here are some measures to ensure the lpFileName is valid.
First, make sure that your printer is SHARED, even if it's on the local machine!!! This alone may be enough to solve the issue.
The following link http://www.answers.com/topic/createfile demonstrates how to prepend the \\?\UNC\ to the first parameter of the CreateFile function, which may resolve the issue for some of you as well. Ideally you want to end up with something like \\?\UNC\computer\printer
joshb
joshb@sane.ca
-- syntactic is our elegance, incisive our disease --
|
|
|
|
|
Hi,
This code looks great, I am looking for something similar but for a Zebra P120i ID Card printer.. I've tried this code, but it sends a job to the queue, processes it, but does nothing...
Cheers
Nick
|
|
|
|
|
Did you find any solution for that ? I have 430i card printer and same thing happens.
|
|
|
|
|
Hi! is there a way to retrieve values return from calling ~HS and ~HI. I don't know if i'm asking the correct question here.
(",)
|
|
|
|
|
Thanks for the code, seems like it works great (mostly). I have tried this on two pc's and it worked flawlessly. I just tried it on another one, and I am getting the "Invalid handle" error.
I am using your dll files, and have tried a variety of handles from LPT1, "ipaddress/sharename", all which worked on the other computers but not this one. Any idea what might cause this?
|
|
|
|
|
Is it possible to use either the DLL or class as part of a web application to print labels on the server side? I have included it in a windows form without problems. In a web form, I get the following error messages:
with DLL:
"Invalid handle. Parameter name: handle"
at line: "print.StartWrite("\\M-shippingxp\\putaway")"
with VB class:
"Invalid handle. Parameter name: handle "
at line: "_outFile = New FileStream(hPortP, FileAccess.Write)"
Any help would be appreciated!
|
|
|
|
|
you should put ("\\\\M-shippingxp\\putaway")
|
|
|
|
|
Hey! i have a similar problem.
If i'm printing from a local application in works fine, even when printing to a shared printer on a different PC.
When i try to print from my asp web site, it throws the "invalid parameter: handle" error.
How do i resolve this issue?
Mihai
|
|
|
|
|
If your web site runs on Windows Server 2008 most likely the error comes from insufficient rights NETWORK SERVICE has on accessing external resources. In this case the only solution I found was to create a normal user, and set pe application pool run on it.
If this is not the case try to get the last IO error using:
System.ComponentModel.Win32Exception ex = new System.ComponentModel.Win32Exception();
errMsg = ex.Message;
and investigate from there...
Mircea
|
|
|
|
|
10x Mircea.
Changing the user solved my problem
Mihai
|
|
|
|
|
Please can you explain where you changed the user in the web config file??
Thank you.
|
|
|
|
|
Has anybody been able to print images (PCX format) to a zebra printer? could you post an example code?. thanks
|
|
|
|
|
Hello.
i've just finished doing this. it's not complicated: you just need to share this code so that the filestream you're using uses the correct encoding (i've used the 1252 encoding).
After changing this, you just need to use the bitmap class and its lockbits method in order to get the stride in order to copy the bits to the stream that is sent to the printer.
i'll be publishing an article about this in my blog in the next days:
http://msmvps.com/blogs/luisabreu
--
Regards,
Luis Abreu
|
|
|
|
|
Hi Luis, thank you for your reply, I've been able to print images to my zebra printers (QL320, QL420+) using an excellent project developed by Vino Rodrigues. His project is "Z-Bar: .NET for Zebra Printer" hosted on http://sourceforge.net/projects/z-bar/[^], wich works with CF2. I didn't specify that I was working with CF1 and it's bitmap class doesn't have a lockbits method. Anyway, I'll read your post as soon as possible.
|
|
|
|
|
The code has been create to use with the LTP port, it works perfect, but if I want to print using the USB port, how can i do it?
Thank you
|
|
|
|
|