Solved

How to print direclty to print server (zebra ZPL code) from vb6

Posted on 2004-07-30
3
12,494 Views
Last Modified: 2012-06-21
The printer is a Zebra z4m, and I'm trying to print a file containing ZPL (zebra programming lang)

I have an existing print solution with the printer directly connected via LPT1, the code I'm using for this works perfectly:
-------working code----------
Open "c:\tropos\sdk\label" For Input As #1
Open "lpt1" For Output As #2
strTMP = Input(LOF(1), #1)
Print #2, strTMP
--------------------------------

The problem occurs when I want to put the printer on a network print server (D-Link DP-301p).

I've tried mapping lpt1 to the print server (net use lpt1: \\...etc) and using the same code as above but it fails (shows Error-printing in XP)

I've also tried using the printer object in vb i.e.:

Open "c:\tropos\sdk\label" For Input As #1
strTMP = Input(LOF(1), #1)
printer.print strtmp
printer.enddoc

but it still just comes up with an error straight away.

I've also tried setting the printer port to lpr printing as well as tcp/ip.

Now I'm truly stuck!
Any ideas anyone??

Jon
0
Comment
Question by:wheelibin
3 Comments
 
LVL 1

Expert Comment

by:aruana
ID: 11675979
Printing to LTP1 is not longer supported by XP and versions beyond.  Also, you are not able to map it to network queues as you have found out.
To send printer commands in windows driver, I now use JOE Hecht's rawprint.pas

There is a link to it here:
http://www.efg2.com/Lab/Library/Delphi/Printing/ 
look for item "Raw" printer access

It enables me to control the printer directly using windows drivers.
So, setup a windows printer driver (use generic type) and map it to the printserver queue.
Then send your printer commands to the driver using rawprint.
Remember to set the printer as default or use this command to set it,
    Printer.PrinterIndex:=n;
where n is the printer driver number.
0
 
LVL 3

Accepted Solution

by:
PocketMatt earned 500 total points
ID: 11676043
Hi wheelibin

what happens if you open the command prompt and copy your printfile with the b - Param to the mapped port?
something like
copy c:\tropos\sdk\label lpt1 /b
if that works you could try if you can work it out with some api calls...
i always used api calls to control priters directly under windows xp.
such as these here..

Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, lpNumberOfBytesWritten As Long, lpOverlapped As OVERLAPPED) As Long

do you have special drivers for the printbox? you could try to install them instead of using the default tcp driver.
0
 
LVL 1

Author Comment

by:wheelibin
ID: 11691425
PocketMatt:

Good shot!  That worked a treat, I may try and use the API calls too but for now the copying is good enough for me.

Cheers for the speedy answer :)
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Magic Software info 18 132
Microsoft C++ code failing in executable that worked 9 101
numbers ascending pyramid 101 196
Change the background and font colors in Notepad++ 5 90
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question