How do I print report from CrystalReport (ASP.NET) on a client side printer.
You have two options:
To simplify what the users had to install on each client I went with the hidden pdf option and a separate button to print to client.
On the aspx page I have an asp literal that I populate with the pdf embeded object at 1px x 1px so it isn't visible to the user. Then on pageload call the printToPrinter method.
// On server side
// Export to PDF
Guid imageGuid = Guid.NewGuid();
string _pdfName = String.Format(@"{0}{1}{2}.pdf", _pdfPath, _reportName, imageGuid);
// expport to unique filename
// ...
// Display the pdf object
_sb.AppendFormat("");
pdfLiteral.Text = _sb.ToString();
pdfLiteral.Visible = true;
// javascript
// on document load call the printWithDialog function
var code = function(){
try
{
var pdf = $get('pdfObject');
if (pdf == null)
return;
try {
pdf.printWithDialog();
}
catch (err) {
alert('Please Install Adobe Acrobat reader to use this feature');
}
}
catch(err)
{
}
};
window.setTimeout(code, 1000);