Solved

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

Posted on 2004-07-30
3
12,578 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Simple Linear Regression

696 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