DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Wed, 15 Aug 2007 18:19:08 +0100,    posted on: microsoft.public.dotnet.framework.compactframework        back       

Thread Index
  1    Peter Morris
          2    Ginny Caughey [MVP]
                 3    Peter Morris
                        4    Ginny Caughey [MVP]


Printing PCX image   
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;
  }
Date:Wed, 15 Aug 2007 18:19:08 +0100   Author:  

Re: Printing PCX image   
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"  wrote in message 
news:eGBJoB23HHA.5316@TK2MSFTNGP04.phx.gbl...

> 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;
>  }
>
>
>
>
>
> 
Date:Wed, 15 Aug 2007 14:57:17 -0400   Author:  

Re: Printing PCX image   
Hi Ginny



> 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.


Do you mean for the whole print job, or just the image?  The problem is that 
a business class uses an abstract PrintDoc class to do things like
OutputText("Your signature");
OutputLine();
OutputImage(SomeImage);

The PrintDoc class descendant then generates the bytes required to perform 
this print job (in this case a string) and this data is saved to a database. 
Later in the day the data is retrieved from the DB and printed in bulk.  So 
unfortunately I can't reference a file on disk or anything, it only exists 
as encoded data within the print job (like a spooler).

Pete
Date:Thu, 16 Aug 2007 15:31:41 +0100   Author:  

Re: Printing PCX image   
Peter,

I mean just the image. Once you have the encoded data, you can convert it to 
a temp file and reference that.

-- 
Ginny Caughey
Device Application Development MVP


"Peter Morris"  wrote in message 
news:OnuIsIB4HHA.1824@TK2MSFTNGP04.phx.gbl...

> Hi Ginny
>
>
>> 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.
>
> Do you mean for the whole print job, or just the image?  The problem is 
> that a business class uses an abstract PrintDoc class to do things like
> OutputText("Your signature");
> OutputLine();
> OutputImage(SomeImage);
>
> The PrintDoc class descendant then generates the bytes required to perform 
> this print job (in this case a string) and this data is saved to a 
> database. Later in the day the data is retrieved from the DB and printed 
> in bulk.  So unfortunately I can't reference a file on disk or anything, 
> it only exists as encoded data within the print job (like a spooler).
>
> Pete
> 
Date:Sat, 18 Aug 2007 07:48:29 -0400   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us