Client Side Printing

i have an asp.net website.

i have created multiple reports and now one of the requirements is to print the reports on the client printer. i am able to achieve this using Javascript but all the formating goes out.

Now what other alternative i have to do the same. appreciate if some1 can help me out on this
Appreciate if some can help me solve this issue.
LVL 9
AsishRajAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mstrelanCommented:
include a css print stylesheet
<link rel="stylesheet" media="print" href="print.css" />

in that css file just hide all the unnecessary elements (like nav bars etc) and set all the widths and styles to fit. in your testing remove media="print" so you can see it on screen but then add it back in to apply it to print only
0
AsishRajAuthor Commented:
i should have mentioned earlier

i printing crystal report on button click.  Code snippet included

print_content only includes the crystal report and nothing else. i am having issue with Crystal Report Layout.

function Clickheretoprint()
{ 
  var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
      disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25"; 
  var content_vlue = document.getElementById("print_content").innerHTML; 
  
  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('<html><head><title></title>'); 
   docprint.document.write('</head><body onLoad="self.print()" style="padding: 0px; margin: 0px"><center>');          
   docprint.document.write(content_vlue);          
   docprint.document.write('</center></body></html>'); 
   docprint.document.close(); 
   docprint.focus();
   var hiddenControl = '<%= CR_PrintLetter.ClientID %>';
   document.getElementById(hiddenControl).style.display = 'none' 
}

Open in new window

0
Muhammad Ousama GhazaliSolution Analyst & ArchitectCommented:
If you are using VS-built in Crystal Reports you may acheive what you are trying to do. The solution that CR provides is actually a mix of sever and client side and by default the printing from the CR is in PDF format so whenever you print a report using the button on the CR control in the webpage, it will automatically create a PDF on the server side as per your page selection and will prompt you to either download or open the PDF which actually can later be printed on the local printer but off course the user have to interact in this scenario with first printing the PDF and then later printing the hard copy from the PDF.
However, there is another option in addition to PDF supported by CR but only on Internet Explorer and utilizes ActiveX. You specify the location of printer-ActiveX in the web.config as mentioned in the code snippet below while you can download this ActiveX from the CR site too and if you need it I can upload it for you too. In addition to specifying this in web.config, you need to set the CR viewer control's PrintMode property to ActiveX from Pdf. Remember, if CR detects it's a non-ActiveX supported browser, it'll automatically switch to PDF mode.
Hope this helps.

<businessObjects>
	<crystalReports>
		<printControl>
			<add key="url" value="http://mywebsiteurl/Installers/PrintControl.cab"/>
		</printControl>
	</crystalReports>
</businessObjects>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

AsishRajAuthor Commented:
yeah, i think thats is a nice way out. appreciate if you can upload the activeX here, so that other people looking at this thread can benefit as well.
0
AsishRajAuthor Commented:
moghazali

i was trying to get it from CR site but couldnt find it
0
AsishRajAuthor Commented:
one question

does printcontrol.cab version needs to be same as the CR version installed with the VS 2008
0
Muhammad Ousama GhazaliSolution Analyst & ArchitectCommented:
The PrintControl is same for VS2005 and VS2008 as we have deployed it in our web applications in both versions.
I tried uploading the PrintControl.cab file but even from within the archive (.zip) EE is not allowing to upload.
Please browse to the following URL and download the .cab file from there:
http://cid-01fca96ef9f91b0d.skydrive.live.com/self.aspx/.Public/PrintControl.cab
Just before posting I found a direct link for the cab file and here it is:
http://support.businessobjects.com/CRforVS2005/PrintControl.cab#1,2,0,1078
Further, see these two links for documentation on printControl:
http://msdn.microsoft.com/en-us/library/ms227537.aspx
http://devlibrary.businessobjects.com/businessobjectsxir2/en/devsuite.htm#en/CrystalReports_dotNET_SDK/crsdk_net_doc/doc/crsdk_net_doc/html/crconfeatureprinting.htm
Hope this helps.
0
AsishRajAuthor Commented:
Thanks for the help. It took me a while to figure out how to do it. Really helpful Links
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.