Re: Printing PCX image

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
PRINT




What I interpret as this

! 0 200 200 500 1
PCX 0 30 {binary data}
FORM
PRINT

or

! 0 200 200 500 1
PCX 0 30
{binary data}
FORM
PRINT


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;
}







.



Relevant Pages

  • Printing PCX image
    ... I am trying to print a B&W PCX image to a Zebra RW420 file. ... uses the CPCL language, the help file says.... ... PCX 0 30 {binary data} ... so I only have access to a string. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Starting from the beginning
    ... Then, it usses an English-language string in the source code, which is ... possible reasons into the useless and incomprehensible "Unable to open CIP file", ... // more processing will be done here like getting the binary data ... /CIP3PreviewImageHeight 726 def ...
    (microsoft.public.vc.mfc)
  • Re: Searching for byte sequence
    ... Several lines of "text" header info followed by 10,000bytes of binary data ... like your text string) then the Find approach will work. ... If n gives me an offset in a string (that ... CString cSelect; ...
    (microsoft.public.vc.mfc)
  • RE: Strange issue while executing sql server sp
    ... references a string or binary data, so it probably isn't the ctns column. ... I have a simple stored procedure in sql server 2005 express version. ...
    (microsoft.public.sqlserver.programming)
  • RE: Strange issue while executing sql server sp
    ... "Vern Rabe" wrote: ... references a string or binary data, so it probably isn't the ctns column. ... I have a simple stored procedure in sql server 2005 express version. ...
    (microsoft.public.sqlserver.programming)