1

我用 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;
}
4

1 回答 1

0

将图像保存到打印机上的 EEPROM 并按名称调用图像。这仅在您只使用一次时才可行。如果您不断生成新的不同图像,那么您依赖于传输介质。

于 2020-02-14T05:22:34.027 回答