Printing first page of report on paper from another tray

Stimulsoft Reports.WPF discussion
Post Reply
User avatar
PJoyeux
Posts: 160
Joined: Tue Nov 26, 2013 9:40 am
Location: Germany

Printing first page of report on paper from another tray

Post by PJoyeux »

Hi,

Is there a way to tell the report that its first page should be printer on paper from "Tray 1" and all following pages from "Tray 2". In Tray1 there is paper with preprinted headers as opposed to "Tray 2" where blank paper is stored.

I saw some entries in the forum that said you have to do this via code, is that true? If so, would you be so kind as to show me in what event and what code is needed?

Thanks and cheers,
Pascal
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Printing first page of report on paper from another tray

Post by HighAley »

Hello.

There are Paper Source of First Page and Paper Source of Second Page property of the Page that you could use for this.

Thank you.
User avatar
PJoyeux
Posts: 160
Joined: Tue Nov 26, 2013 9:40 am
Location: Germany

Re: Printing first page of report on paper from another tray

Post by PJoyeux »

Hi,

thanks for the answer but are these properties accessible from within the designer or only in code? I couldn't find them in the designer.

Can you show me an example on how to set these properties? If indeed this has to be done from code, then "where?" and "how?"

Thanks,
Pascal
User avatar
PJoyeux
Posts: 160
Joined: Tue Nov 26, 2013 9:40 am
Location: Germany

Re: Printing first page of report on paper from another tray

Post by PJoyeux »

Any hint here? Or code snippets?

Would be greatly appreciated, thanks!

Cheers,
Pascal
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Printing first page of report on paper from another tray

Post by HighAley »

Hello.

Unfortunately, these properties were not implemented in the WPF Designer because it was impossible in WPF.
As we know it's impossible to set different paper trays for different pages.

Thank you.
User avatar
PJoyeux
Posts: 160
Joined: Tue Nov 26, 2013 9:40 am
Location: Germany

Re: Printing first page of report on paper from another tray

Post by PJoyeux »

Wow, that's some bad news! :o

I can't believe that nobody needs this!?!? This is an essential feature...

So what would you suggest as a solution? One report with different pages, two reports? Some code in some events? There's got to be a way to change the tray... :?

Pascal
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Printing first page of report on paper from another tray

Post by HighAley »

Hello.

The main problem is that it's impossible to set paper source in WPF.
You could find more information on the Visual Studio forum.
There is no universal method to do this.

Thank you.
User avatar
PJoyeux
Posts: 160
Joined: Tue Nov 26, 2013 9:40 am
Location: Germany

Re: Printing first page of report on paper from another tray

Post by PJoyeux »

Well just as an information for anybody being confronted with the same question. I did it this way:

Using informations I gathered from http://social.msdn.microsoft.com/Forums ... windowsxps I was able to create my own ModifyPrintTicket() Method.

I then used this in a Method "GetPrinterTrays(aPrinter)" to get all trays available to a given printer and a Method "SetPrinterTray (aPrinter, aTray)" to set a given Tray in a PrintTicket and returning it.

Using the returned PrintTicket I then called PrintWithWpf the following way (simplified):

Code: Select all

PrintTicket objPrintTicket = SetPrinterTray("MyPrinter", "TrayForFirstPage");
objReport.PrintWithWpf (objPrintTicket, false, 1, 1, ......);

PrintTicket objPrintTicket = SetPrinterTray("MyPrinter", "TrayForFollowingPages");
objReport.PrintWithWpf (objPrintTicket, false, 2, objReport.RenderedPages.Count, ......);
That way I am able to choose different trays for the first and all the following pages... Of course you can do this to change the tray only for the fourth and/or fifth page or whatever you need.

The drawback is, that you have to know at what printing-pagenumber you want to change the trays. So if you use bands or pages in your report and want certain bands/pages to be printed on another tray then this is not a solution for you since you can't tell after which printing-page to make the change... In this case you might want to use some events that tell you when a band/page is going to be printed and change the trays there. But I don't know how and if you can send a new PrintTicket to the Printing-System from within a PrintJob...

I hope this helps somebody

Cheers,
Pascal
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Printing first page of report on paper from another tray

Post by HighAley »

Hello.

Thank you for your solution.
Post Reply