Link to home
Start Free TrialLog in
Avatar of AsishRaj
AsishRajFlag for Fiji

asked on

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.
Avatar of mstrelan
mstrelan
Flag of Australia image

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
Avatar of AsishRaj

ASKER

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

ASKER CERTIFIED SOLUTION
Avatar of Muhammad Ousama Ghazali
Muhammad Ousama Ghazali
Flag of Saudi Arabia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
moghazali

i was trying to get it from CR site but couldnt find it
one question

does printcontrol.cab version needs to be same as the CR version installed with the VS 2008
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the help. It took me a while to figure out how to do it. Really helpful Links