0

I am using the ComponentOne Winforms suite, specifically the FlexReport control, to generate output which will be sent directly to one of several printers. This isn't, I believe, an issue with the ComponentOne suite as I was having similar issues with Crystal.

The end result will run as a VB .Net windows service, but I am having real problems getting it to work. The current code is as follows:

Dim factory As New DatabaseProviderFactory()
Dim sysDb As SqlDatabase
Dim dsOrderList As New DataSet
Dim dsOrderDetail As New DataSet

Dim frPicklist55 As New C1.Win.FlexReport.C1FlexReport
Dim p1 As C1.Win.FlexReport.ReportParameter
Dim options As C1PrintOptions = New C1PrintOptions()
options.PrinterSettings = New PrinterSettings()
options.PageSettings = New System.Drawing.Printing.PageSettings()
'options.PrinterSettings.PrinterName = "\\printsvr\printername"
'options.PrinterSettings.PrinterName = "\\\\printsvr\\printername"
options.PrinterSettings.PrinterName = "Printer1"

sysDb = factory.Create("sys")

dsOrderList = sysDb.ExecuteDataSet("sp_apispool_getorders")

For Each r In dsOrderList.Tables(0).Rows
    dsOrderDetail = sysDb.ExecuteDataSet("sp_apispool_getorder", r("order_no"))

    frPicklist55.Load("D:\API Spooling Docs\Rpt55Picklist.flxr", "Picklist")
    frPicklist55.Parameters("OrderNo").Value = r("order_no")
    frPicklist55.Render()

    frPicklist55.Print(options)

Next

Specifically, the issues are:

  • If I use a shared printer ('\printsvr\printername' or '\\printsvr\printername'), I get an exception about the printer settings not being valid.
  • If I use the local printer ('Printer1'), I get an exception -'Operation is not supported'

This should be really simple, but I suspect I am missing something fundamental. No matter what I do I get an exception at the point I call the Print function.

Any ideas?

Si Stone
  • 31
  • 1
  • Do you need those lines to assign values to options.PrinterSettings and options.PageSettings? – Brian THOMAS Sep 08 '17 at 09:51
  • Well, that might be what I am missing. There is little or no documentation on what is required from this namespace, but `options.PrinterSettings.PrinterName = "Printer1"` is at least setting the printer name on the local machine. What is interesting is that if I iterate the `System.Drawing.Printing.PrinterSettings.InstalledPrinters` collection, it doesn't list shared printer queues, only local ones - hence my creating a local queue to try that... – Si Stone Sep 08 '17 at 11:50

1 Answers1

0
    Dim filter As New C1.Win.C1Document.Export.PdfFilter()
    filter.ShowOptions = False
    filter.FileName = "C:\Temp\Print.pdf"

    For Each r In dsOrderList.Tables(0).Rows

        dsOrderDetail = sysDb.ExecuteDataSet("sp_apispool_getorder", r("order_no"))

        frPicklist55.Load("D:\API Spooling Docs\Rpt55Picklist.flxr", "Picklist")
        frPicklist55.Parameters("OrderNo").Value = r("order_no")
        frPicklist55.RenderToFilter(filter)

    Next

    Dim ps As New PrinterSettings()
    ps.PrinterName = "\\printsvr\printername"
    Dim pdfdoc As New C1.Win.C1Document.C1PdfDocumentSource()
    pdfdoc.LoadFromFile(filter.FileName)
    pdfdoc.Print(ps)
David Chai
  • 11
  • 3