Solved

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

Posted on 2004-07-30
3
12,460 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This is an explanation of a simple data model to help parse a JSON feed
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

759 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now