如何将.grf文件打印到斑马打印机内存

时间:2014-10-15 22:35:16

标签: c# printing zebra-printers zpl zpl-ii

我在C#中开发了一个应用程序,它将图像打印到斑马打印机上。

我的斑马纹是 Zebra打印机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;
}

提前致谢

1 个答案:

答案 0 :(得分:0)

将图像保存到打印机的EEPROM中,然后按名称调用该图像。仅在仅使用一次的情况下才可行。如果您不断生成新的不同图像,那么您将依赖于传输介质。