【问题标题】:VB.NET 2013 Crystal Report print to printer directly without displayingVB.NET 2013 Crystal Report 直接打印到打印机不显示
【发布时间】:2019-03-04 16:36:15
【问题描述】:

我正在开发 VB.Net 2013 + Crystal Reports 项目。任务是根据用户标准从 MSSQL 中获取发票数据,并将其直接打印到预定义的打印机上。在这样做的同时,发票的布局将按照客户提供的方式使用。所以这是在 Crystal Reports 中完成的。

问题是如何将水晶报表直接打印到打印机而不在屏幕上显示任何报表。

请指教。

【问题讨论】:

  • 你可以请一些代码,你卡在哪里?

标签: vb.net printing crystal-reports


【解决方案1】:

我找到了这个问题的替代解决方案。我从这个站点使用了 Adob​​e Acrobat 的命令行开关:https://www.robvanderwoude.com/commandlineswitches.php#Acrobat

使用此开关,我可以将 PDF 发送到任何物理打印机。然而,PDF 创建是使用 BullPDF 打印机 (http://www.bullzip.com/products/pdf/info.php) 完成的,它是一个免费的 PDF 打印机应用程序。

所以完整的逻辑如下:

  1. 在 Crystal Reports 2013 中根据客户规范设计自定义报表

  2. 使用以下代码将报表从 Crystal Reports 打印到 PDF 打印机:

私有子 RunReport() Dim CryRpt 作为新的 ReportDocument 将 crTblLogInfos 调暗为新 TableLogOnInfos 将 crTblLogInInfo 调暗为新 TableLogOnInfo 将 crConInfo 调暗为新的 ConnectionInfo 将 crTables 调暗为表格 将 crTable 调暗为表格

    With crConInfo
        .ServerName = ServerName
        .DatabaseName = DBName
        .UserID = UID
        .Password = Pwd
    End With

    CryRpt.Load(FPath & "rptLink.rpt")

    crTables = CryRpt.Database.Tables
    For Each crTable In crTables
        crTblLogInInfo = crTable.LogOnInfo
        crTblLogInInfo.ConnectionInfo = crConInfo
        crTable.ApplyLogOnInfo(crTblLogInInfo)
    Next
    CryRpt.PrintOptions.PrinterName = "Bullzip PDF Printer"
    CryRpt.PrintToPrinter(1, False, 0, 0)

    OrdersLinking.DocPrinted = True
    Me.Close()

End Sub
  1. 上述步骤会将报告以 PDF 格式保存到 Bull PDF Printer 中提到的预定义文件夹中。现在使用https://www.robvanderwoude.com/commandlineswitches.php#Acrobat 中提到的以下命令将 PDF 文件发送到物理打印机

静默打印 PDF 文件:

AcroRd32.exe /N /T PdfFile PrinterName 

任务完成。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-12-10
    • 1970-01-01
    • 2014-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多