Reputation: 391
I am using crystal report 11, ASP .NET 3.5
I want any clue/suggestions for printing crystal report without viewing the data in crystalreportviewer.
One option i have is to export the crystal report to PDF and then print. But how can i print PDF file without opening it.I do not want to specify the printer from code.
I want to select the printer from print dialogue box.The printer could be network printer.
I would also like to know whether there is any third party tool.
Please provide your suggestions.
Thank you
Upvotes: 1
Views: 4250
Reputation: 3428
In my asp.net web app I use Crystal to generate a PDF that gets streamed to the client. That requires that the users have to have a PDF viewer installed.
Some of my code:
protected void Page_Init(object sender, EventArgs e)
{
string repName = Request.QueryString.Get("report");
ReportDocument rpt = new ReportDocument();
rpt.Load(Server.MapPath(repName));
System.IO.Stream oStream;
byte[] byteArray = null;
oStream = rpt.ExportToStream(ExportFormatType.PortableDocFormat);
byteArray = new byte[oStream.Length];
oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1));
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.BinaryWrite(byteArray);
Response.Flush();
Response.Close();
}
Hope that helps.
Upvotes: 5