Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PCL in Visual Basic

Status
Not open for further replies.

gowda111

Programmer
Sep 15, 2003
1
US
Hi,
Iam new to PCL. We want to create a packing slip using PCL in visual basic. Can you please tell what is needed to use PCL commands in Visual Basic. And if anyone has sample code for me to start with that will be great help.

Thanks
Kothi
 
Kothi,

Firstly, are you sure you should do it direct from VB without using a report writer?

But if you do want to do it straight from VB, here's some thoughts. You'll need to learn the PCL commands first.... somewhere in this board there's a url for electronic copies of the PCL manuals if you've not got them already. Once you figure out the commands you need, you need to create output strings in your VB code, to send to the printer. The escape code, which is part of each PCL command is Ascii character 27, so you need a Chr(27) in the strings at the appropriate point.

But here's the problem.... usually, when you use the printer object in VB to print with, it puts MORE PCL code round what you send (or PostScript, depending on the driver you use) and that messes the whole thing up.

So one of my colleagues found a reference at MicroSoft on how to do what they call Raw Printng, which is direct to the printer not thru' the driver. We experimented with it and it does work. Here's the url:
In the VB code, you will see they create a string called sWrittenData which they send to the printer. If for example you make that string something like....

sWrittenData = Chr(27) & "(s4101T"

that would set the typeface to CG Times which is typeface number 4101. (The typeface command is esc(s#T where the # is the typeface number.)

You need to construct a whole lot of strings like that, each one with the commands to do what you want, and the text you want to print, of course.

HTH?




Jim Brown,
Johannesburg,
South Africa.
My time is GMT+2
 
I have created an PCL/HPGL class (collection of methods & functions) in a 4gl called Progress that could be easily translated into VB, if you're interested. (jnebi@landam.com)
 
Are you sure that you want to write pcl directly. vb6 has a printer object thats very easy to use and can print to any windows printer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top