Printing in background

Hi,
I want to create a service to print my reports with a json to a specific printer.
I created the code below for it, but I get the following error

combit.Reporting.LL_Parameter_Exception
  HResult=0x80131500
  Message=Parameter error
  Source=combit.ListLabel27
  StackTrace:
   at combit.Reporting.LLException.CheckReturn(Int32 returnValue)
   at combit.Reporting.LlCore.LlXSetParameter(LlExtensionType extensionType, String extensionName, String name, String value)
   at combit.Reporting.ListLabel.SetExportOptions(LlPrintMode printMode)
   at combit.Reporting.ListLabel.PrintReportFromRelationalDataSourceNewMode(IDataProvider dataSource, String projectFile, Boolean showFileSelect, LlPrintMode printMode, LlBoxType boxType, String dialogTitle, Boolean showPrintOptions, String tempPath)
   at combit.Reporting.ListLabel.AutoPrint(LlProject projectType, String projectFile, Boolean showFileSelect, LlPrintMode printMode, LlBoxType boxType, String dialogTitle, Boolean showPrintOptions, String tempPath)
   at combit.Reporting.ListLabel.Print(Object userData, LlProject projectType, String projectFile, Boolean showFileSelect, LlPrintMode printMode, LlBoxType boxType, IntPtr windowHandle, String dialogTitle, Boolean showPrintOptions, String tempPath)
   at combit.Reporting.ListLabel.Print(LlProject projectType, String projectFile, Boolean showFileSelect, LlPrintMode printMode)
   at combit.Reporting.ListLabel.Print(LlProject projectType, String projectFile, Boolean showFileSelect)
   at combit.Reporting.ListLabel.Print(LlProject projectType)
   at combit.Reporting.ListLabel.Print()
   at combit.Reporting.ListLabel.Print(String printerName)


  This exception was originally thrown at this call stack:
    [External Code]
    Program.<Main>$(string[]) in Program.cs
ListLabel LL = new ListLabel();
TextReader reader = File.OpenText(@"F:\Data\Projects\RbA\DB Wiki + Json\transaction.json");
JsonDataProvider provider = new JsonDataProvider(reader);
LL.DataSource = provider;
LL.ExportOptions.Add("Export.Target", "PRN");
LL.AutoProjectFile = @"F:\Data\Projects\RbA\report1.cds";
LL.Print(@"\\dc05\HP Laserjet 410 - Infra");
LL.Dispose();

Actually, you’d not set “Export.Target” to “PRN” (the target is reserverd to the export formats) but rather use

LL.AutoDestination = LlPrintMode.Normal

instead. And - of course - make sure the printer is accessible for the service user.

1 Like

Hi Jochen,

It works, Thank you

2 Likes

I have just tried @jbartlau. It works. Thank you so much!

2 Likes