工单打印

This commit is contained in:
qianhao.xu
2024-12-11 17:24:15 +08:00
parent 7aaf36f1a0
commit 73b6acd375
10 changed files with 302 additions and 112 deletions

View File

@@ -20,6 +20,7 @@ namespace Infrastructure
public CustomException(string msg) : base(msg)
{
Msg = msg+"为空,检查前端";
}
public CustomException(int code, string msg) : base(msg)
{

View File

@@ -14,6 +14,7 @@
<PackageReference Include="AspectCore.Abstractions" Version="2.4.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="QuestPDF" Version="2025.1.0-alpha0" />
<PackageReference Include="UAParser" Version="3.1.47" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.10" />
<PackageReference Include="JinianNet.JNTemplate" Version="2.4.2" />
@@ -21,6 +22,8 @@
<PackageReference Include="CSRedisCore" Version="3.8.803" />
<PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
<PackageReference Include="IP2Region.Net" Version="2.0.2" />
<PackageReference Include="ZXing.Net" Version="0.16.9" />
<PackageReference Include="ZXing.Net.Bindings.ZKWeb.System.Drawing" Version="0.16.7" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,52 @@
using System.Drawing;
using System.Drawing.Imaging;
using System.DrawingCore;
using System.DrawingCore.Imaging;
using ZXing;
using ZXing.Common;
namespace DOAN.Infrastructure.Helper;
public class PrintHelper
{
/// <summary>
/// 打印条形码
/// </summary>
/// <param name="message"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <returns></returns>
public static byte[] CreateBarCode(string message, int width, int height)
{
if (string.IsNullOrWhiteSpace(message))
{
return null;
}
var w = new ZXing.OneD.Code128Writer();
BitMatrix b = w.encode(message, BarcodeFormat.CODE_128, width, height);
var zzb = new ZXing.ZKWeb.BarcodeWriter();
zzb.Options = new EncodingOptions()
{
Margin = 3,
PureBarcode = false
};
Bitmap b2 = zzb.Write(b);
using (var ms = new System.IO.MemoryStream())
{
b2.Save(ms, ImageFormat.Png);
var bytes = ms.ToArray();
return bytes;
}
}
}