Re: Printing PCX image
- From: "Ginny Caughey [MVP]" <ginny.caughey.online@xxxxxxxxxxxxxx>
- Date: Wed, 15 Aug 2007 14:57:17 -0400
Peter,
I haven't tried printing an image although I have worked with Zebra printers. My *guess* is that you will need to create a temp file for the image and pass that to the printer, then delete it. I think those printers expect a carriage return and line feed after each line, and you may need to Sleep() some milliseconds after each line of data sent to the printer. For this reason, I'd suggest writing each line to the serial port separately rather than all at once. You may also need to delay closing the serial port to the printer for some little bit to ensure that all the data is sent. One last suggestion - for testing also print some normal Hello world text before and after the image to make sure you're getting anything printed.
HTH,
--
Ginny Caughey
Device Application Development MVP
"Peter Morris" <support@xxxxxxxxxxxxxxxxxxxx> wrote in message news:eGBJoB23HHA.5316@xxxxxxxxxxxxxxxxxxxxxxx
Hi all
I am trying to print a B&W PCX image to a Zebra RW420 file. The printer uses the CPCL language, the help file says....
Input 1 (STARTPCX.LBL):
! 0 200 200 500 1
PCX 0 30
Input 2 (IMAGE.PCX)
Input 3 (ENDPCX.LBL)
FORM
What I interpret as this
! 0 200 200 500 1
PCX 0 30 {binary data}
FORM
or
! 0 200 200 500 1
PCX 0 30
{binary data}
FORM
Neither of these are working. I have tried sending the binary data directly as ASCII.GetBytes, and also tried reading each byte and converting it to an ASCII HEX format 00-FF.
Does anyone have any experience with this? The guy on the support desk seems to think this is enough, but it is just doing nothing at all! Any help appreciated.
PS: I cannot use a file reference in the PCX, I must embed the file data into the string because I am storing it away in a DB and printing it later so I only have access to a string.
private void button1_Click(object sender, EventArgs e)
{
StringBuilder data = new StringBuilder();
data.Append("! 0 200 200 500 1\r\n");
data.Append("PCX 0 30 ");
data.Append(HexEncodedPCXData("/SDMMC DISK/x.pcx") + "\r\n");
data.Append("FORM\r\n");
data.Append("PRINT\r\n");
byte[] binary =
System.Text.ASCIIEncoding.ASCII.GetBytes(data.ToString());
//Output the file just so I can see what it is sending
FileStream fs = new FileStream("/SDMMC Disk/output.bin",
FileMode.Create);
fs.Write(binary, 0, binary.Length);
fs.Close();
ZebraPrintCtlClass zebraPrinter = new ZebraPrintCtlClass();
try
{
zebraPrinter.SerialConnection(string.Format("COM{0}:", 6), 19200);
zebraPrinter.Open();
zebraPrinter.Print(data.ToString());
}
finally
{
zebraPrinter.Close();
}
}
private string HexEncodedPCXData(string fileName)
{
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read,
FileShare.None);
byte[] buffer = new byte[fs.Length];
BinaryReader reader = new BinaryReader(fs);
using (reader)
reader.Read(buffer, 0, (int)fs.Length);
string result = System.Text.ASCIIEncoding.ASCII.GetString(buffer, 0,
buffer.Length);
return result;
}
.
- Follow-Ups:
- Re: Printing PCX image
- From: Peter Morris
- Re: Printing PCX image
- References:
- Printing PCX image
- From: Peter Morris
- Printing PCX image
- Prev by Date: Re: EXE file version info?
- Next by Date: Problem with Vista and passthrough & VS 2005
- Previous by thread: Printing PCX image
- Next by thread: Re: Printing PCX image
- Index(es):
Relevant Pages
|