Hi all !
I've come across a huge problem (for me at least).
I'm trying to send some initial graphics to a labelprinter. To do this, I load the graphics from
resource and send it directly to the printerport along with "printer instructions".
The problem is that the printer instruction have to be "plain text" while the image has to be
binary. Something like this:
....
....
02D
02ICPCOD
<Binary data goes here>
More plain text goes here
.....
.....
If I use StreamWriter, the everything is plain text, and if I use BinaryWriter everythings is
binary. Any help are greatly appreciated.
TIA
Kai Bohli
Norway
Code below:
<snip>
private void btnInitDatamax_Click(object sender, System.EventArgs e)
{
Assembly assem = this.GetType().Assembly;
Stream F9Stream =
assem.GetManifestResourceStream(this.GetType(),"Re sources.SvPost.Foretak9.bmp");
PrintDialog pd = new PrintDialog();
pd.PrinterSettings = new PrinterSettings();
if (DialogResult.OK == pd.ShowDialog(this))
{
MemoryStream memStrm = new MemoryStream();
StreamWriter sw = new StreamWriter(memStrm);
sw.WriteLine("\x02n");
sw.WriteLine("\x02M1891");
sw.WriteLine("\x02O0220");
sw.WriteLine("\x02O0220");
sw.WriteLine("\x02SG");
sw.WriteLine("\x02d");
sw.WriteLine("\x02c0757");
sw.WriteLine("\x02D");
sw.WriteLine("\x02ICPForetak9");
sw.WriteLine("");
sw.Flush();
// append the image stream
long length = F9Stream.Length;
byte [] bytes = new byte[length];
//sw.Write(bytes,0,(int)length);
//bw.Write(pictureBox1.Image);
//bw.Write(Foretak9);
//bw.Write()
sw.WriteLine("\x02L");
sw.WriteLine("D11");
sw.WriteLine("PG");
sw.WriteLine("pG");
sw.WriteLine("SG");
sw.WriteLine("A2");
sw.WriteLine("1Y1100005890137Foretak9");
sw.WriteLine("Q0001");
sw.WriteLine("E");
sw.WriteLine("");
sw.Flush();
memStrm.Position = 0;
LabelPrintHelper.SendDocToPrinter(pd.PrinterSettin gs.PrinterName,memStrm);
sw.Close();
}
}
</snip>
Best wishes
Kai Bohli
ka***********@online.no
Norway