Setting printer dynamically

We are adding L&L reports to an existing application. The app currently has a system that has a setup for different printers globally for the app. For example the invoice printer is set to a specific printer on the network.

Actually there are multiple invoice printers for the different offices and the printer to print an invoice is chosen based on the location the order is shipped from.

in addition each user has the ability on each workstation to override the globally defined invoice printer to a different printer that may be closer to that users workstation

in the existing system that is really easy by simply setting the printer before printing the report.

looking at L&L it looks like the printer information is an integral part of the project and the project actually has to be modified and saved to change the printer.

does this mean that in order to support the above we would have to create a copy of each project for each user?

And then of course if the main document changes design they would all have to be recreated again?

Or did i miss something that would allow this to be easier?



_report.Core.LlSetPrinterInPrinterFile(projectType, llFileName, “Microsoft XPS Document Writer”);

guess i wasnt clear.

I know how to set the printer with LLSetPrinterInPrinterFile but that modifies the project file for all users as far as i can see

Actually, the printer information is stored in a separate file. You can set a a user specific path for this file by calling LlSetPrinterDefaultsDir. If you set this to a local path, each user is free to have her own configuration.

Note that the user needs to check the option to permanently apply changes in the print dialog, otherwise any change will be temporarily only. Does this help :slight_smile: ?

interesting. that allows a user wanting to use a different printer for a specific report

but it looks like then every user will have to define the printer for the report (and all reports) or is it possible to have a global file and a user specific file

currently we are using a global setting for each printer. And with printer i mean a virtual printer such as InvoicePrinter1_Location1. The invoice report automatically defaults to that global printer setting.

now if a user wants to print invoices next to his workstation that user can change the setting for InvoicePrinter1_Location1 to a printer next to his workstation. This will change all invoice reports printed in location1 to use that override but will still use global printer settings for all other printers for ex invoice_location2.

am i correct that the printer settings file is per L&L project and i am also guessing that if i change the LlSetPrinterDefaultsDir there is no option to still use the global files from another folder

adding a new report would then also require each user to set up the printer for the report?


You could simply check if a user specific configuration exists and temporarily copy the global configuration if it doesn’t. LlPrintCopyPrinterConfiguration might be useful for this purpose, although a simple file copy should also work.