You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.3 KiB
C#

using Seagull.BarTender.Print;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace SlnMesnac.LabelPrint.Bartender.equip
{
public abstract class PrintEquip
{
protected Engine engine = new Engine(true);
protected LabelFormatDocument EngineFormat;
public object ParaClass;
//模板名称
public string tempPath = "";
public string findModePath()
{
//string filePath =Common.Instance.TempBasePath;
//filePath = filePath + tempPath;
string filePath = tempPath;
Console.WriteLine("打印路径:" + filePath);
return filePath;
}
public abstract bool AddPara();
public bool Open()
{
bool result = false;
try
{
string modePath = findModePath();
if (File.Exists(modePath))
{
EngineFormat = engine.Documents.Open(modePath);
result = true;
Console.WriteLine("文件打开成功" + modePath);
}
else
{
Console.WriteLine("未找到文件" + modePath);
}
}
catch (Exception e)
{
Console.WriteLine("文件打开失败");
result = false;
}
return result;
}
public bool print()
{
bool result = false;
if (EngineFormat != null)
{
if (AddPara())
{
Result re = EngineFormat.Print();
result = re == Result.Success ? true : false;
string st = re == Result.Success ? "成功" : "失败";
Console.WriteLine("文件打印" + st + re.ToString());
}
else
{
Console.WriteLine("下传参数失败");
}
}
return result;
}
public void Colse()
{
try
{
EngineFormat.Close(SaveOptions.DoNotSaveChanges);//不保存对打开模板的修改
engine.Stop();
}
catch
{ }
}
}
}