How to print second report after the first?

1 Answer 55 Views
.NET Framework Report Viewer - HTML5
Paul
Top achievements
Rank 1
Iron
Paul asked on 10 Jul 2024, 04:20 PM

I have a html5 report viewer that loads a report book, of which is hidden, with a print button shown that issues the print command. Viewer is hidden as I just want a print button and this was the only approach to do that shows the print dialog.

Anyways, that report book contains two reports. First one is a sales report, the other are items part of that sale. It was to simulate a functionality that I ported over from a function in MS Access to as close as possible. The report loaded and printed fine.

However, it needs to be now changed. The reports need to be printed on two different sizes. The sales report is fine the current dimensions. However, the items need to be sent to a printer that prints on 4x6 cards.

The idea I came up with is have two report viewers and load the individual reports and have the printEnd client event of the sales report to trigger the print of the items report. However, that doesn't work as that looks to immediately trigger the print of the items report and skips printing sales.

My question would be is there a way to print the next report after the first report is printed?

1 Answer, 1 is accepted

Sort by
0
Accepted
Momchil
Telerik team
answered on 15 Jul 2024, 11:53 AM

Hi Paul,

I would not recommend printing the reports through a hidden report viewer for performance considerations. Even if the viewer is visually hidden, it will still query an HTML5 rendering for its preview which can cause delays, especially if the reports are larger. Instead, I would suggest using the approach from the following Knowledge Base article.

Print a Report Directly at Client-Side Without Displaying It in a Viewer.

The article contains a demo you can test on your end. You will notice that the client side of the project sends a fetch request to a specific server-side endpoint to get the PDF of the desired report. This should allow you to print either the combined report book or the individual reports without the overhead of using the viewer.

Regarding how you can print the two reports one after the other. I have not tested printing multiple PDF files with one user action but I suppose you can try the approach from the following Stack Overflow thread.

Printing multiple PDF files using JavaScript - Stack Overflow

Alternatively, perhaps you can use the Window: afterprint event of the first printing to trigger the second printing.

I hope this helps.

Regards,
Momchil
Progress Telerik

Stay tuned by visiting our roadmap and feedback portal pages, enjoy a smooth take-off with our Getting Started resources, or visit the free self-paced technical training at https://learn.telerik.com/.
Paul
Top achievements
Rank 1
Iron
commented on 24 Jul 2024, 01:36 PM

Thank you for your response. I implemented the first part of your solution in rendering PDFs rather the viewer. 

As to regarding printing multiple in an action, those didn't work for my use case. The stack overflow link, used physical files. It didn't like the blob link. I would have to add the iframe to the print window. There seemed to be a delay in it loading. Another route it lead me to is something similar above, but you use the PDF js library. That is however if you didn't want to use the iframe in the print window.

As to the Window: afterprint event, that didn't work for me. Using it in the iframe, did do anything. From what I can gather it can only be used in html documents, and since this was a pdf mime type, it wouldn't work.

Tags
.NET Framework Report Viewer - HTML5
Asked by
Paul
Top achievements
Rank 1
Iron
Answers by
Momchil
Telerik team
Share this question
or