cancel
Showing results for 
Search instead for 
Did you mean: 

How can I control printing on CR for VS2022 SP34? Round 2.

pjhunter
Discoverer
0 Kudos
490

yoganandamuthaiah offered some good suggestions to my original question, but the answer is still unclear to me. My situation: I have a web page that interacts with the user to assembe data for a report into a strongly typed dataset which is assigned to the report document using the .setDataSource property of the report document. The report is displayed properly and I can navigate through it without problem.

However, when the user clicks the "Print" button in the CR toolbar, the report is sent as a .pdf with the name of the viewer control (crViewer) as it's title into the user's downloads folder as "crViewer.pdf"

What I would really like to do is replace the print button in the tool bar with my own which would open up a user dialog asking if they wanted to save the report as a PDF and give a meaningful name to the saved file, OR, send the report directly to the default printer on their system.

I have found similar questions (and answers) but they are based on windows forms, not web pages. When I debug my web page in VS and set breakpoints and I examine the crViewer control, as well as the rptDocument object, I can find no reference to the print button in any object. It appears that for web page applications, all the configuration and work is done via javascript.

The answer to this issue using windows forms is as I would suspect: hide the print button, scan through all the toolbar controls and add a new print button control and a handler pointing to an application method. This answer is referenced here.

I just can't find a pathway to do this in a web environment.

Thank you.

Accepted Solutions (1)

Accepted Solutions (1)

DonWilliams
Active Contributor
0 Kudos

Hi Peter,

R&D replied and the problem is we did have a PrintController ActiveX plug-in that IE would used and it used a Windows Print Dialog box. Since IE is no longer supported and IE was the only browser that still supported ActiveX the default Print Dialog is now to export it to PDF.

Currently R&D is looking into options to do something with the print button in the WEB Viewer.

There is no API to replace the Viewers Print Button.

You could do this:

CrystalReportViewer1.HasPrintButton = false;

So the user doesn't see CR's print button and add your own print button using something like the example in my test app.

Not sure why it defaults to the Viewer name, Windows Form uses the SummaryInfo.Title when exporting.

Option to export the report and once it's exported then use Windows API's to rename the file and then print so the name shows up as the file name.

Bottom line is R&D is working on what to do with the button, the default is to use the Viewer Name as the print job name.

What would you like it to do? Now is the time to suggest to R&D what the work flow would/should/could be..

Don

Answers (1)

Answers (1)

DonWilliams
Active Contributor
0 Kudos

Hi Peter.

I believe you can replace the Print button but it's not supported because the Button ID's are not locked so they could change with each patch.

You should be able to overlay the Viewers Button with your own, I don't have any samples though.

For selecting a printer See if this helps:

website7vs2015-copyzip.txt

Rename by removing the .txt and then unzip it.

Then change this line to select you report:

string url = "/inetpub/wwwroot/WebSite7VS2015/Drill Down Group Level.rpt";

And copy the CR viewer files from:

C:\inetpub\wwwroot\aspnet_client\system_web\4_0_30319\crystalreportviewers13

Into

C:\inetpub\wwwroot\WebSite7VS2015 - Copy\aspnet_client\system_web\4_0_30319\crystalreportviewers13

What it should be doing is using the SummaryInfo.Title as the print name.

I recall I had a discussion about this with R&D but now that I'm retired I no longer have access to my mail history.

I'll Ping one of the Developers and see if he recalls how to.

Have a great day

Don