【问题标题】:How to duplex and staple a print job如何双面和装订打印作业
【发布时间】:2015-10-20 14:43:04
【问题描述】:

我想从 Excel 打印到 Postscript,然后打印到打印机。如何在将打印作业发送到打印机之前指定双面打印和装订。

我一直在看PrintTicket class。看起来很有希望。但我正在使用带有 .net 3.5 的 WinForms 项目。

如果没有必要,我真的不想设置多个打印队列。那么如何控制双面和装订选项呢?

Public Shared Function PrintSheetsToPS(ByVal wb As Excel.Workbook, _
                                       ByVal arr As Array, _
                                       ByVal PSFileName As String) As String

    Dim svInputPS As String = TempPath & PSFileName
    IO.File.Delete (svInputPS)
    wb.Worksheets(arr).PrintOut(PrintToFile:=True, _
                                  PrToFileName:=svInputPS, _
                                  ActivePrinter:=PSPrinterName)

    Return svInputPS

End Function

【问题讨论】:

    标签: vb.net printing


    【解决方案1】:

    您可以使用PrintQueue.AddJob 方法将文件添加到打印队列中。但它只接受 XPS 文档。然后您可以使用PrintTicket 类来指定双工和/或装订。不要使用 Postscript,而是打印到 XPS 并使用它添加作业。

    Public Shared Function PrintSheetsToXPS(ByVal wb As Excel.Workbook, _
                                           ByVal arr As Array, _
                                           ByVal XPSFileName As String) As String
    
        Dim svInputPS As String = TempPath & XPSFileName
        IO.File.Delete (svInputPS)
        wb.Worksheets(arr).PrintOut(PrintToFile:=True, _
                          PrToFileName:=svInputPS, _
                          ActivePrinter:="Microsoft XPS Document Writer")
    
        Return svInputPS
    
    End Function
    
    Sub demoDuplexStaple(ByVal XPSFileName As String)
        'Imports SysPrint = System.Printing
        'need to reference ReachFramework
        Dim PrintServer As New SysPrint.PrintServer("\\" & My.Computer.Name)
        Dim PrintQ As New SysPrint.PrintQueue(PrintServer, "Ricoh Main")
        Dim Jobs As SysPrint.PrintJobInfoCollection = PrintQ.GetPrintJobInfoCollection
        Dim able As SysPrint.PrintCapabilities = PrintQ.GetPrintCapabilities()
    
        'get the current PrintTicket
        Dim CurrentTicket As SysPrint.PrintTicket _
                = PrintQ.CurrentJobSettings.CurrentPrintTicket
    
        'modify to staple and duplex
        CurrentTicket.Stapling = Printing.Stapling.StapleTopLeft
        CurrentTicket.Duplexing = Printing.Duplexing.TwoSidedLongEdge
    
        'add the XPS file to the print queue to print
        Dim TestJob As SysPrint.PrintSystemJobInfo _
                = PrintQ.AddJob("Test job", XPSFileName, False)
    
    End Sub
    

    如果您需要 PDF,您可以使用 GhostXPS 将 XPS 转换为 PDF。不幸的是,目前同时有no way to add bookmarks。但将来可能是addressed

    【讨论】:

      猜你喜欢
      • 2012-06-23
      • 2019-09-10
      • 2012-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多