using FastReport;
|
using FastReport.Barcode;
|
using FastReport.Table;
|
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
using System.Text.Json;
|
using System.Text.Json.Serialization;
|
|
namespace Print.Controllers
|
{
|
[ApiController]
|
[Route("[controller]")]
|
public class PrintController : Controller
|
{
|
//const string PrintName = @"\\192.168.99.3\Gprinter GP-3120TU";
|
|
[HttpGet, HttpPost, Route("PrintPalletCode"), AllowAnonymous]
|
public object PrintPalletCode([FromBody] List<string> PalletCodes)
|
{
|
try
|
{
|
foreach (var item in PalletCodes)
|
{
|
string ReportPathmater = System.IO.Directory.GetCurrentDirectory();
|
string MFile = string.Empty;
|
MFile = ReportPathmater + "\\frx\\PalletCode.frx";
|
Report report = new Report();
|
report.Load(MFile);
|
report.PrintSettings.ShowDialog = false;
|
System.Drawing.Printing.PrinterSettings oitem = new System.Drawing.Printing.PrinterSettings();
|
report.PrintSettings.Printer = oitem.PrinterName;
|
BarcodeObject OrderNoObj = report.FindObject("PalletCode") as BarcodeObject;
|
if (OrderNoObj != null)
|
{
|
OrderNoObj.Text = item;
|
}
|
report.Print();
|
report.Dispose();
|
}
|
return new { Code = 400, Status = false, Message = "打印成功" };
|
}
|
catch (Exception ex)
|
{
|
return new { Code = 400, Status = false, Message = "打印失败,请查看是否连接打印机" };
|
}
|
}
|
}
|
}
|