Combination printing: determine printers for individual projects

From List & Label 30, the DefinePrintOptions event is triggered for each individual project of the combination print (see also NextCombinationPrintStep event) in order to be able to determine the printer, tray, etc. used in each case, for example.

The DOM API is used for the implementation in order to be able to access the project to be printed in the DefinePrintOptions event.

The following code snippet shows how a separate printer is assigned in the second and third project of the combination print in .NET.

// helper: represents the currently active project
// to define different printers
private int counter = 0;

private void BTN_Print_Click(object sender, EventArgs e)
{
	counter = 0;
	using (ListLabel LL = new ListLabel())
	{
		// define used data source
		LL.DataSource = SqlConnectionDataProvider();
		
		// define the projects for combination print
		// by separating them by a semicolon
		string proj1 = Path.Combine(startPath, "template01.lst");
		string proj2 = Path.Combine(startPath, "template02.lst");
		string proj3 = Path.Combine(startPath, "template03.lst");
		string projects = proj1 + ";" + proj2 + ";" + proj3;
		
		// register the event DefinePrintOptions to get called
		// for each project before printing to define its 
		// individual used printer
		LL.DefinePrintOptions += LL_DefinePrintOptions; 
		
		ExportConfiguration exportConfig =
			new ExportConfiguration(
								LlExportTarget.Pdf, 
								@"C:\temp\export.pdf", 
								projects
								);
		LL.Export(exportConfig);
	}
}

private void LL_DefinePrintOptions(object sender, EventArgs e)
{
	// get the current loaded list project with DOM
	ProjectList proj = new ProjectList(sender as ListLabel);
	proj.GetFromParent();

	// define the used printer to use for the projects
	if (counter == 1)
	{
		proj.Regions[0].Device.Name = 
		     "\"Microsoft Print to PDF\"";
	}
	else if (counter == 2)
	{
		proj.Regions[0].Device.Name = 
		     "\"Microsoft XPS Document Writer\"";
	}
	
	// save the changes in the current loaded project
	proj.Save();
	
	counter++;
}