473,608 Members | 2,264 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Printer language & sending commands

Hello,

I can't find a way to send printer specific language codes to printer.

Part of my code :
String sString = "B50,0,0,3,1,2, 50,B," + "12345678901234 567890";
Font fFont = new Font("Arial", 16);
SolidBrush bBrush = new SolidBrush(Colo r.Black);
PointF pPoint = new PointF(150.0F, 150.0F);
ev.Graphics.Dra wString(sString , fFont, bBrush, pPoint);

First part of the sString should tel my printer to print a barcode. But all
I get is the whole sString contens printed out as-it-is.
I assume the problem is that I send graphical representation of sString to
printer and not a sequence of characters.
Should I try Streams or ......?????

Printer is Eltron TLP2046 BarCode Printer

thx,
Damijan the Puzzled
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.
Nov 16 '05 #1
3 29509
Hi !

You need to send the data raw to the printer, otherwise Windows will eat the control codes alive.

First of all read this article:
HOW TO: Send Raw Data to a Printer by Using Visual C# .NET
http://support.microsoft.com/?kbid=322091

Copy the article code into a classfile.
Then you'll have to do something like the code below. (sorry about the formating )

(Note: The SendDocTo Printer is my addon to the article, where I have added a few methods so I could
pass a memorystream, and stream from a embedded resource file etc.
I have a lot of experience with Eltron Orion/2443 and Zebra 2443/2444 and DataMax label printers,
but almost everything I've done is done in Delphi. I've jsut started porting this stuff to C#
myself. Anyway, if you're stucked - contact me and I can see if I can help you - no garantee though
:)
<snip>
private void btnPrint2_Click (object sender, System.EventArg s e)
{
PrintDialog pd = new PrintDialog();
pd.PrinterSetti ngs = new PrinterSettings ();
if (DialogResult.O K == pd.ShowDialog(t his))
{
MemoryStream memStrm = new MemoryStream();
StreamWriter sw = new StreamWriter(me mStrm);
sw.WriteLine("\ x02L");
sw.WriteLine("H 07");
sw.WriteLine("D 11");
sw.WriteLine("1 911008020000251 0K Ny linje");
sw.WriteLine("1 911008010000251 0K OHM 1/4 WATT");
sw.Flush();
sw.WriteLine("1 a62100000000505 90PCS");
sw.WriteLine("E ");
sw.WriteLine("" );
sw.Flush();

memStrm.Positio n = 0;
LabelPrint.Send DocToPrinter(pd .PrinterSetting s.PrinterName,m emStrm);
sw.Close();

</snip>

<snip2>
private void btn3_Click(obje ct sender, System.EventArg s e)
{
PrintDialog pd = new PrintDialog();
pd.PrinterSetti ngs = new PrinterSettings ();
if (DialogResult.O K == pd.ShowDialog(t his))
{
string p = pd.PrinterSetti ngs.PrinterName ;
LabelPrint.Send StringToPrinter (p,"\x02L"); // ^BL
LabelPrint.Send StringToPrinter (p,"H07");
LabelPrint.Send StringToPrinter (p,"D11");
LabelPrint.Send StringToPrinter (p,"19110080100 002510K OHM 1/4 WATT");
LabelPrint.Send StringToPrinter (p,"1a621000000 0050590PCS");
LabelPrint.Send StringToPrinter (p,"E");
LabelPrint.Send StringToPrinter (p,"");
}
}
</snip2>
On Tue, 6 Jul 2004 14:38:31 +0200, "Vlki" <damijan.gradis er_at_neckerman n_si> wrote:
Hello,

I can't find a way to send printer specific language codes to printer.

Part of my code :
String sString = "B50,0,0,3,1,2, 50,B," + "12345678901234 567890";
Font fFont = new Font("Arial", 16);
SolidBrush bBrush = new SolidBrush(Colo r.Black);
PointF pPoint = new PointF(150.0F, 150.0F);
ev.Graphics.Dr awString(sStrin g, fFont, bBrush, pPoint);

First part of the sString should tel my printer to print a barcode. But all
I get is the whole sString contens printed out as-it-is.
I assume the problem is that I send graphical representation of sString to
printer and not a sequence of characters.
Should I try Streams or ......?????

Printer is Eltron TLP2046 BarCode Printer

thx,
Damijan the Puzzled


Best wishes
Kai Bohli
ka***********@o nline.no
Norway
Nov 16 '05 #2
"Kai Bohli" <ka****@online. nospam> ha scritto nel messaggio
news:71******** *************** *********@4ax.c om...
Hi !

You need to send the data raw to the printer, otherwise Windows will eat the control codes alive.
First of all read this article:
HOW TO: Send Raw Data to a Printer by Using Visual C# .NET
http://support.microsoft.com/?kbid=322091

Copy the article code into a classfile.
Then you'll have to do something like the code below. (sorry about the formating )
(Note: The SendDocTo Printer is my addon to the article, where I have added a few methods so I could pass a memorystream, and stream from a embedded resource file etc.
I have a lot of experience with Eltron Orion/2443 and Zebra 2443/2444 and DataMax label printers, but almost everything I've done is done in Delphi. I've jsut started porting this stuff to C# myself. Anyway, if you're stucked - contact me and I can see if I can help you - no garantee though :)


Hi,
I'm trying to print on an Eltron TLP2247. Using the example that you
suggest, nothing appen on the printer.
How can i sent EPL command do the printer?

Thnks
EMA
Nov 16 '05 #3
Hi Emanuele !

Sorry for the late answer. The sample that I posted was for a Datamax printer. So in Eltron/Zebra,
it should go something like this:

char sn = '"';
MemoryStream memStrm = new MemoryStream();
StreamWriter sw = new StreamWriter(me mStrm);
sw.WriteLine("\ n"); // new line to start command structure
sw.WriteLine("N "); // clear image memory from last printed label
sw.WriteLine("X 0,0,4,752,584") ; // draw a box
sw.WriteLine("L O0,144,752,4"); // draw a line
sw.WriteLine("A 40,400,1,1,1,1, N," + sn + "Made in Norway" + sn);
sw.WriteLine("B 280,440,0,1,2,3 ,96,B," + sn + "S 000001" + sn); // write a barcode
sw.Flush();
sw.WriteLine("P 1"); // print 1 label
sw.WriteLine("" ); // empty line
sw.Flush();

memStrm.Positio n = 0;
LabelPrint.Send DocToPrinter(pd .PrinterSetting s.PrinterName,m emStrm);
sw.Close();

The sample above is simple, but it's all I had time to do now. Not that you should add a method to
the article file called SendDocToPrinte r. I've posted the code below:
<code for the SendDocToPrinte r function>
public static bool SendDocToPrinte r( string szPrinterName, MemoryStream ms)
{
// Open the file.
//FileStream fs = new FileStream(szFi leName, FileMode.Open);
// Create a BinaryReader on the file.
BinaryReader br = new BinaryReader(ms );
// Dim an array of bytes big enough to hold the file's contents.
Byte []bytes = new Byte[ms.Length];
bool bSuccess = false;
// Your unmanaged pointer.
IntPtr pUnmanagedBytes = new IntPtr(0);
int nLength;

nLength = Convert.ToInt32 (ms.Length);
// Read the contents of the file into the array.
bytes = br.ReadBytes( nLength );
// Allocate some unmanaged memory for those bytes.
pUnmanagedBytes = Marshal.AllocCo TaskMem(nLength );
// Copy the managed byte array into the unmanaged array.
Marshal.Copy(by tes, 0, pUnmanagedBytes , nLength);
// Send the unmanaged bytes to the printer.
bSuccess = SendBytesToPrin ter(szPrinterNa me, pUnmanagedBytes , nLength);
// Free the unmanaged memory that you allocated earlier.
Marshal.FreeCoT askMem(pUnmanag edBytes);
return bSuccess;
}
</code for the SendDocToPrinte r function>

I'm trying to print on an Eltron TLP2247. Using the example that you
suggest, nothing appen on the printer.
How can i sent EPL command do the printer?

Thnks
EMA

Best wishes
Kai Bohli
ka***********@o nline.no
Norway
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1931
by: Nis Sarup | last post by:
A customer of mine wants to make a newsletter for their website. The newsletter should be HTML with images and sent to a database of her subscribers. They would like a script where they can easily compose and send the newsletter. I can write that, but wouldnt like to reinvent the weel. Does anybody here have any good recomendations on newsletter composing/sending software? Userfriendliness and simplicity is the key. TIA, Nis.
1
3784
by: Zaidan | last post by:
I am running Excel2000 under WIN98 2nd edition, and I am writing a VBA code (I will consider using javascript if I have to) that does the following, at the user command: 1- Start MS Explorer and go to my website. Login (enter ID and Password) 2- It will go and update some prices of some products that I sell 3- It will add new products or cancel some product I already have someone who wrote me in JavaScript a web form (no documentation...
0
3774
by: masterjuan | last post by:
Networks Hacking (hack C:/ drives, severs...)and security holes all on my website & hacking commands and I explain ways of erasing your tracks so you dont get caught doing "bad" things... What do you think? check out my website its about hacking networks and step by step guides of how to do it all. Any suggestions on information or anything you think would be interesting to write about please tell me. Also what do you think of the...
1
4181
by: trs204 | last post by:
For moving the files, planning to use like this..... find / -iname "*.txt" -type f -exec /bin/mv {} /mnt/bckup \; I want to do compressing before moving the files. Please suggest. I am not sure, if it is possible to use 2 commands using find. thanks in advance.
2
4441
by: hari | last post by:
Hi all, I need to automate printer command testing, prinetr supports parallel/ serial/USB.How can i send the commands from python to printer. I have got pyparallel, as am new to python, no idea how to work on it. Please give some tips,The comamnd to be sent to the printer is hex data "1B 40".please give a example,it will be grateful.
0
1260
by: Astan Chee | last post by:
Hi, Im trying to implement the logic from http://www.hypothetic.org/docs/msn/general/http_connections.php to a simple python code using urllib2 and some parts of urllib. Im behind a http proxy that requires authentication that is why Im using urllib2. Im asking for help on how to send commands in a body of a HTTP before requesting for response. What am I doing wrong? I only get the response from the server but my commands never seem to be...
0
989
by: rhyspatto | last post by:
Hi, I have a problem but cannot figure out a good solution to it. I am trying to create a form that creates a bunch of panels during runtime, and I want to be able to send commands (such as false visibility, etc) to the panels also during runtime. Once I create a bunch of panels (each using the same 'creation' code), how can I call them up again to send commands to them? I figure I can add them to an array and call them using:...
0
1917
by: Kineta | last post by:
Hello all, I am attempting to send commands to the firmware on my PIC18F4550 (usb port) microcontroller using Pyserial. If I open Hyperterminal, I can send the following commands and it works beautifully: set_dac(0,1500,0) report_smu Then I went to Python with Pyserial, and nothing happens. I get no errors, but at the same time the board does not respond to the input, and python prints no output. Here is my code:
0
1588
by: mctadas | last post by:
Hello, for some time I'm struggling with Argox printer trying to print Cyrillic characters and some other non-ASCII characers. I believe this question is related to this one about sending printer commands. What I'm trying to do here, is to send soft font to printer using ES command and I hope to get expected behavior. But I cannot figure out how to do it in c#. It would be great if someone could provide a working example of code. ...
0
8063
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8496
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8475
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8148
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8338
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6013
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3962
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2474
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1594
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.