【问题标题】:How to know the print task is aborted using ActiveReport SystemPrinter?如何知道使用 ActiveReport SystemPrinter 中止打印任务?
【发布时间】:2018-09-18 03:48:10
【问题描述】:

我对 ActiveReport 完全陌生。

我有一个使用 ActiveReport 2.0 的旧版 VB6 代码。 打印流程如下(代码是VB,ar的初始化没有显示)

Dim ar as DDActiveReports2.ActiveReport

Dim aborted As Boolean
aborted = False
ar.Printer.StartJob("some job")
For i = 0 To ar.Pages.Count - 1
  ar.Printer.StartPage()
  If ar.Printer.Status = DDActiveReports2.JobStatus.ddJSAborted Then
    ar.Printer.AbortJob()
    aborted = True
    Exit For
  End If
  ar.Printer.PrintPage(ar.Pages(i), left, top, width, height)
  ar.Printer.EndPage()
Next
If Not Aborted Then
  ar.Printer.EndJob()
End If

我正在尝试将其迁移到 ActiveReport for .NET。经过一番研究,我发现这里最好的替代品是 ActiveReports.SystemPrinter。迁移后的代码可能如下(未显示 ar 的初始化),

Dim ar As ActiveReports.Document.SectionDocument

Dim aborted As Boolean = False
Dim printer As New ActiveReports.SystemPrinter
printer.StartJob("some job")
For i = 0 To ar.Pages.Count - 1
  printer.StartPage()
  If ??? Then
    printer.AbortJob()
    aborted = True
    Exit For
  End If
  ar.Pages(i).Draw(printer.Graphics, New RectangleF(left, top, width, height))
  printer.EndPage()
Next
If Not Aborted Then
  printer.EndJob()
End If

但是,我无法在 ActiveReport2 中找到 printer.Status,并且无法知道打印中止状态 DDActiveReports2.JobStatus.ddJSAborted。

我不太确定 DDActiveReports2.JobStatus.ddJSAborted 到底是什么,我猜用户可能会在 Windows 打印任务窗口中取消打印。一旦取消,程序将取消所有剩余页面。

但是,这似乎不能在 .NET 中完成?我错过了什么吗?

请帮忙。

谢谢。

【问题讨论】:

    标签: .net printing reporting activereports


    【解决方案1】:

    .NET 版本中的 SectionDocument 类具有 PrintAborted 事件处理程序。 这是一个代码示例:

    导入 GrapeCity.ActiveReports

    导入 GrapeCity.ActiveReports.Document

        Dim WithEvents my_document As SectionDocument
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        my_document = New SectionDocument()
        my_document.Load(ms)
        my_document.Print(False)
    End Sub
    
    Private Sub PrintAborted(sender As Object, e As EventArgs) Handles my_document.PrintAborted
        MsgBox("PrintAborted")
    End Sub
    

    请不要忘记将项目中的引用添加到 GrapeCity.ActiveReports.Extensibility.dll 和 GrapeCity.ActiveReports.Viewer.Win.dll

    谢谢,

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多