I need to change printer and tray setting depending on every single page data.

Stimulsoft Reports.Net discussion
Post Reply
User avatar
ercan
Posts: 18
Joined: Thu Feb 07, 2019 8:21 am

I need to change printer and tray setting depending on every single page data.

Post by ercan » Tue May 07, 2019 10:31 am

I need to change printer and tray setting depending on every single page data.

So example if I have that page content type is 1: I have to sent it to the FirstFloor printer.
But if page content type is 2: I must be go to the printer SecondFloor printer.
3: must be go to the other printer.
Can I manage it on the before print every page?

I have StiPrintProvider.QueryPageSettings += StiPrintProvider_QueryPageSettings;
With this event I can manage Printer Tray settings and it is ok.
But in this method I have only Page Settings, Paper Source and PaperSize properties.
I dont have target printer settings.
Also I dont have print data for decision of target print.

I need to set target printer. On every different page. Not for whole of report.

Can you help me?
User avatar
ercan
Posts: 18
Joined: Thu Feb 07, 2019 8:21 am

Re: I need to change printer and tray setting depending on every single page data.

Post by ercan » Tue May 07, 2019 11:06 am

I found a solution. Im using this way but I'm not sure is it best practice :
So I'm printing pages one by one from datasource not from printpreview. I'm not sure.

Code: Select all


	var pageNumber = 1;

                foreach (DataRow dataRow in myTable.Rows)
                {
                    PageSettings printerSettings =((PageSettings)GetSettings[dataRow[DataRowTemplateIdColumnName]]);

                        stiViewerCertificates.Report.Print(false, new PrinterSettings()
                        {
                            PrinterName = printerSettings.PrinterSettings.PrinterName,
                            Copies = 1,
                            PrintRange = PrintRange.SomePages,
                            FromPage = pageNumber,
                            ToPage = pageNumber,
                            PaperSources = { printerSettings.PaperSource},
                            DefaultPageSettings = { PaperSource = printerSettings.PaperSource},
                        });

                    pageNumber++;
                }
Lech Kulikowski
Posts: 1991
Joined: Tue Mar 20, 2018 5:34 am

Re: I need to change printer and tray setting depending on every single page data.

Post by Lech Kulikowski » Wed May 08, 2019 9:18 pm

Hello,

Thank you for the provided solution.
Post Reply