找回密码
 立即注册

QQ登录

只需一步,快速开始

lkxtracy

金牌服务用户

12

主题

57

帖子

195

积分

金牌服务用户

积分
195
lkxtracy
金牌服务用户   /  发表于:2019-1-10 11:28  /   查看:2978  /  回复:3
在对多张表格做批量pdf打印的时候,会出现报错中断的问题。调用源码逻辑是在一个独立的线程中对文件做循环,New FpSpread() ->Open->PrintSheet
具体堆栈信息:

System.InvalidOperationException
  HResult=0x80131509
  Message=对象当前正在其他地方使用。
  Source=System.Drawing
  StackTrace:
   在 System.Drawing.Graphics.get_Clip()
   在 System.Drawing.GraphicsContext..ctor(Graphics g)
   在 System.Drawing.Graphics.Save()
   在 FarPoint.Win.Spread.SpreadView.a(WindowsGraphics A_0, SheetView A_1, Int32 A_2, Int32 A_3, Graphics A_4, PdfGraphics A_5)
   在 FarPoint.Win.Spread.SpreadView.b(Graphics A_0, SheetView A_1, Graphics A_2, PdfGraphics A_3)
   在 FarPoint.Win.Spread.FpSpread.a(PdfGraphics A_0, SheetView A_1)
   在 FarPoint.Win.Spread.FpSpread.a(Object A_0, dp A_1)
   在 fj.a(dp A_0)
   在 fj.a(MemoryStream A_0)
   在 fj.d(String A_0)
   在 FarPoint.Win.Spread.FpSpread.a(Int32 A_0, Boolean A_1)
   在 FarPoint.Win.Spread.FpSpread.c(Object A_0)
   在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   在 System.Threading.ThreadHelper.ThreadStart(Object obj)




3 个回复

倒序浏览
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2019-1-12 01:11:49
沙发
不支持开线程同时打印,您需要将多个spread 合并后再导出。
合并可以通过sheet 的open和save方法去做
for
var spread = new spread()
spread.open()
spread.sheet[0].save("xml")
var sheet = new sheet()
sheet.open("xml")
spread1.addsheet(sheet)
回复 使用道具 举报
lkxtracy
金牌服务用户   /  发表于:2019-1-14 13:40:39
板凳
dexteryao 发表于 2019-1-12 01:11
不支持开线程同时打印,您需要将多个spread 合并后再导出。
合并可以通过sheet 的open和save方法去做
for ...

不是多个打印任务分开线程,所有打印任务都是同一个后台线程内执行的。提交到打印机是没问题的,但是导出PDF的话就会报那个错
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2019-1-15 12:09:00
地板
还是资源占用的问题,现在导出pdf没有回调事件,所以不建议批量去做,还是合并后一次导出保险。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部