I came up with a work around for this. Since Crystal Reports does not allow overriding the buttons I ended up hiding the print button and adding my own print button using JavaScript/jQuery.
Here is some under-the-hood info on how the printing works. When you press the print button it does a postback with the view states and event arguments. The post back returns a PDF file which the browser opens inline. The PDF file is embedded with a print command which is executed when the file is opened.
So what we can do is use a hidden IFRAME to load the printable PDF. This way the main page is not affected. I think the PDF loading inline is what causes the page/browser to corrupt its state.
Place the below code at the top of your ASPX page. You must place it at the top of the page otherwise the print dialog will be off the screen if you put it at the bottom.
Here is the HTML:
<iframe id="HiddenFrame" name="HiddenFrame" style="display: none;"></iframe>
<form id="PrintForm" action="MyPage.aspx" method="post" target="HiddenFrame">
<input type="hidden" name="__CRYSTALSTATECrystalReportViewer1" id="CRState" />
<input type="hidden" name="__VIEWSTATE" id="VState" />
<input type="hidden" name="__EVENTTARGET" value="CrystalReportViewer1" />
<input type="hidden" name="__EVENTARGUMENT" value='{"text":"PDF", "range":"false", "tb":"crpdfprint"}' />
</form>
As mentioned above, the IFRAME will load our PDF. The form is used to do a POST to the server with the view states and event arguments. The target
attribute tells the form to load in the IFRAME.
Here is the JavaScript:
$('#CrystalReportViewer1_toptoolbar_print').hide();
$('#CrystalReportViewer1_toptoolbar_print').parent().append('<div id="PrintButtonOverride"></div>');
$('#PrintButtonOverride').click(function () {
$('#CRState').val($('#__CRYSTALSTATECrystalReportViewer1').val());
$('#VState').val($('#__VIEWSTATE').val());
$('#PrintForm').submit();
});
The click event copies the two view states from the main page and then submits the form. I wrote this post quickly so I apologize if I left something unclear.