凭证打印时候,如果凭证摘要里面引入了低位非打印字符,则会报打印失败,如下图所示:
可以在套打插件里面处理一下,将凭证摘要信息里面的低位非打印字符过滤掉。
表单插件:
列表插件:
扩展下凭证,将插件挂上去:
将插件拷贝到website/bin下面,重启IIS, 重新打印预览,可以正常打印处理了:
[code]表单插件:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kingdee.BOS.Core;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.List.PlugIn;
using Kingdee.BOS.Core.QueryInvoke;
using Kingdee.BOS.Core.SqlBuilder;
using Kingdee.BOS;
using Kingdee.BOS.Util;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.Bill;
using Kingdee.BOS.Core.Bill.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Orm.Metadata.DataEntity;
using System.IO;
using Kingdee.BOS.Core.Metadata.FieldElement;
using Kingdee.BOS.Core.Metadata.EntityElement;
using System.Data;
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Core.Metadata;
namespace TestPrintPlugin
{
public class PZPrintPlugin : AbstractBillPlugIn
{
public override void OnPrepareNotePrintData(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.PreparePrintDataEventArgs e)
{
if (e.DataSourceId.Equals("FEntity", StringComparison.OrdinalIgnoreCase))
{
//在原数据包基础上修改套打字段的值
if (e.DataObjects != null)
{
foreach (DynamicObject obj in e.DataObjects)
{
//修改一般字段值
if (obj.DynamicObjectType.Properties.ContainsKey("FEXPLANATION"))
{
string FEXPLANATION = obj["FEXPLANATION"] as string;
FEXPLANATION = Utils.ReplaceLowOrderASCIICharacters(FEXPLANATION);
obj["FEXPLANATION"] = FEXPLANATION;
}
}
}
}
base.OnPrepareNotePrintData(e);
}
}
}[/code][code]列表插件:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.Metadata.FieldElement;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Orm.Metadata.DataEntity;
using Kingdee.BOS.Core.List.PlugIn;
using Kingdee.BOS.ServiceHelper;
using TestPrintPlugin;
namespace TestListPrintPlugin
{
public class PZListPrintPlugin : AbstractListPlugIn
{
public override void OnAfterPrint(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterPrintEventArgs e)
{
base.OnAfterPrint(e);
}
public override void OnPrepareNotePrintData(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.PreparePrintDataEventArgs e)
{
if (e.DataSourceId.Equals("FEntity", StringComparison.OrdinalIgnoreCase))
{
//在原数据包基础上修改套打字段的值
if (e.DataObjects != null)
{
foreach (DynamicObject obj in e.DataObjects)
{
//修改一般字段值
if (obj.DynamicObjectType.Properties.ContainsKey("FEXPLANATION"))
{
string FEXPLANATION = obj["FEXPLANATION"] as string;
FEXPLANATION = Utils.ReplaceLowOrderASCIICharacters(FEXPLANATION);
obj["FEXPLANATION"] = FEXPLANATION;
}
}
}
}
base.OnPrepareNotePrintData(e);
}
}
}
[/code][code]using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestPrintPlugin
{
public static class Utils
{
///
/// 把一个字符串中的 低序位 ASCII 字符 替换成 字符
/// 转换 ASCII 0 - 8 -> � -
/// 转换 ASCII 11 - 12 -> -
/// 转换 ASCII 14 - 31 -> -
///
///
///
public static string ReplaceLowOrderASCIICharacters(string tmp)
{
StringBuilder info = new StringBuilder();
foreach (char cc in tmp)
{
int ss = (int)cc;
if (((ss >= 0) && (ss <= 8)) || ((ss >= 11) && (ss <= 12)) || ((ss >= 14) && (ss <= 32)))
{
//info.AppendFormat("{0:X};", ss);
}
else
{
info.Append(cc);
}
}
return info.ToString();
}
}
}
[/code]
推荐阅读