1729446 - The print job queuing becomes very slow when using custom paper size in Crystal Reports through PrintToPrint method

SAP Knowledge Base Article - Public

1729446 - The print job queuing becomes very slow when using custom paper size in Crystal Reports through PrintToPrint method

Symptom

  • The print job queuing becomes very slow when using custom paper size in Crystal Reports through PrintToPrint method

Environment

  • Crystal Reports 2008 V1
  • Microsoft Visual Studio 2005/2008
  • Custom Paper Size

Reproducing the Issue

The following code is an example and it takes long time to queue print jobs when calling PrintToPrinter method.  

e.g.

Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click

Dim printername As String = cmbPrinter.Text
Dim papersize As System.Drawing.Printing.PaperSize = CType(cmbPaper.SelectedItem, System.Drawing.Printing.PaperSize)

Dim ds As New DataSet

reportDoc.Load("C:\test.RPT")
ds.ReadXml("C:\test.xml")
reportDoc.SetDataSource(ds)

' Set Printer Name
reportDoc.PrintOptions.PrinterName = printername
' Set Paper Size
reportDoc.PrintOptions.PaperSize = papersize.RawKind

Dim printerSettings As New System.Drawing.Printing.PrinterSettings
Dim pageSettings As New System.Drawing.Printing.PageSettings

reportDoc.PrintOptions.CopyTo(printerSettings, pageSettings)
printerSettings.Copies = 1

pageSettings.PaperSize = PaperSize

Dim PrintLayout As New CrystalDecisions.Shared.PrintLayoutSettings

' Set false to DissociatePageSizeAndPrinterPaperSize
reportDoc.PrintOptions.DissociatePageSizeAndPrinterPaperSize = False
PrintLayout.Scaling = PrintLayoutSettings.PrintScaling.DoNotScale

' Execute Print to printer
reportDoc.PrintToPrinter(printerSettings, pageSettings, False, PrintLayout)

End Sub

Private Sub cmbPrinter_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbPrinter.SelectedIndexChanged

' Get a selected printer information
PrintDoc.PrinterSettings.PrinterName = CType(sender, ComboBox).Text
cmbPaper.Items.Clear()

' Get Paper Size information of selected printer
For Each ps As System.Drawing.Printing.PaperSize In PrintDoc.PrinterSettings.PaperSizes
    cmbPaper.Items.Add(ps)
    Next
    cmbPaper.Text = CType(cmbPaper.Items(0), System.Drawing.Printing.PaperSize).PaperName

End Sub

Resolution

Workaround: Use Report Application Server(RAS) component(PrintOutputController.PrintReport), instead of PrintToPrinter method.

Private Sub RASPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RASPrint.Click

Dim pDoc As System.Drawing.Printing.PrintDocument
pDoc = New System.Drawing.Printing.PrintDocument
Dim rasPROpts As CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions
rasPROpts = New CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions
Dim PrintLayout As CrystalDecisions.Shared.PrintLayoutSettings
PrintLayout = New CrystalDecisions.Shared.PrintLayoutSettings

Dim rptClientDoc As CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument

Dim ds As New DataSet
reportDoc.Load("C:\test.RPT")
ds.ReadXml("C:\test.xml")
reportDoc.SetDataSource(ds)

rptClientDoc = reportDoc.ReportClientDocument

Dim papersize As System.Drawing.Printing.PaperSize = CType(cmbPaper.SelectedItem, System.Drawing.Printing.PaperSize)
Dim printername As String = cmbPrinter.Text

rasPROpts.PaperSize = papersize.RawKind
rasPROpts.PrinterName = printername
rasPROpts.JobTitle = reportDoc.FileName.ToString
rasPROpts.NumberOfCopies = 1

rptClientDoc.PrintOutputController.PrintReport(rasPROpts)

End Sub

Private Sub cmbPrinter_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbPrinter.SelectedIndexChanged

' Get a selected printer information
PrintDoc.PrinterSettings.PrinterName = CType(sender, ComboBox).Text
cmbPaper.Items.Clear()
' Get Paper Size information of selected printer
For Each ps As System.Drawing.Printing.PaperSize In PrintDoc.PrinterSettings.PaperSizes
    cmbPaper.Items.Add(ps)
Next
cmbPaper.Text = CType(cmbPaper.Items(0), System.Drawing.Printing.PaperSize).PaperName

End Sub

 

Keywords

user defined paper size, VB.NET, .NET, orientation, landscape, print job, print queue, scale, default printer, server properties, Windows application , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem

Product

Crystal Reports 2008 V1