添加项目文件。
This commit is contained in:
36
Print.Application/Print/GoDEXPrintBase64Image.cs
Normal file
36
Print.Application/Print/GoDEXPrintBase64Image.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JingGong.Abp.Print.GoDEX
|
||||
{
|
||||
/// <summary>
|
||||
/// 按base64打印图片
|
||||
/// </summary>
|
||||
public class GoDEXPrintBase64Image : GoDEXPrintImage
|
||||
{
|
||||
/// <summary>
|
||||
/// Base64数据
|
||||
/// </summary>
|
||||
public string ImageBase64 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取图片数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected override byte[] GetImageData()
|
||||
{
|
||||
var base64Content = ImageBase64;
|
||||
// 检查是否包含 Base64 前缀
|
||||
if (base64Content.Contains("base64,"))
|
||||
{
|
||||
// 去除 "data:image/<format>;base64," 头部信息
|
||||
base64Content = base64Content.Substring(base64Content.IndexOf(",") + 1);
|
||||
}
|
||||
|
||||
return Convert.FromBase64String(base64Content);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user