ゼブラプリンターに画像を印刷するアプリケーションを C# で開発しました。
私のゼブラプリントはゼブラプリンター104S版です。画像をプリンターに印刷するときはいつでも、画像を印刷するのに時間がかかり、画像はラベルの少し下から始まります。
私が尋ねようとしているのは、変換された GRF イメージをプリンターに送信する方法です。高速で印刷する必要があり、新しい画像を印刷するたびにゼブラ プリンタのメモリをフラッシュする必要がある場合。これどうやってするの。
コードスニペット:
private void print_Click(object sender, EventArgs e)
{
string s = image_print() + Print_image();
PrintFactory.sendTextToLPT1(s);
/*string Filename = img_path.Text;
MessageBox.Show("file", Filename);
// if (Filename.ToCharArray().Intersect(Path.GetInvalidFileNameChars()).Any())
// return;
File.Delete(Path.Combine(@"E:\Debug", Filename));*/
}
private string image_print()
{
OpenFileDialog ofd = new OpenFileDialog();
string path = "";
string full_path = "";
string filename_noext = "";
ofd.InitialDirectory = @"C:\ZTOOLS\FONTS";
ofd.Filter = "GRF files (*.grf)|*.grf";
ofd.FilterIndex = 2;
ofd.RestoreDirectory = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
filename_noext = System.IO.Path.GetFileName(ofd.FileName);
path = Path.GetFullPath(ofd.FileName);
img_path.Text = filename_noext;
//MessageBox.Show(filename_noext, "Filename");
// MessageBox.Show(full_path, "path");
//move file from location to debug
string replacepath = @"E:\Debug";
string fileName = System.IO.Path.GetFileName(path);
string newpath = System.IO.Path.Combine(replacepath, fileName);
if (!System.IO.File.Exists(filename_noext))
System.IO.File.Copy(path, newpath);
}
StreamReader test2 = new StreamReader(img_path.Text);
string s = test2.ReadToEnd();
return s;
}
private string Print_image()
{
//^XA^WDE:*.GRF^FS^XZ
string s = "";
s += "^XA^LH" + "" + "," + "" + "^FO0,0^XGR" + img_path.Text + ".GRF,1,1^FS";
s += "^FO184,155^A0N,47,36^FD" + "" + "^FS";
s += "^FO250,235^AFN,33,0^FD" + "" + "^FS";
s += "^FO500,561^A0N,24,19^FD" + "" + "^FS";
s += "^XZ";
return s;
}