hi...
I am using webservice to print a document ,this code wroks from visual studio but not works after hosting it in iis..PLz help...
Here is my code:
public void chefOrderPrinting(OrderFromService objOrder)
{
try
{
DataTable dtOrderDetails = new DataTable();
dtOrderDetails = objOrder.OrderDetails.ListToDataTable();
ReportParameter[] arrParams = new ReportParameter[1];
arrParams[0] = new ReportParameter("rpt_TableNo", objOrder.tableName);
ReportPrintClass objReportPrintClass;
objReportPrintClass = new ReportPrintClass("DataSetChefWorkForService_Rpt_ChefWorkForService", dtOrderDetails, @"Report\ChefWorkForService.rdlc", arrParams, 8.27, 11.69, 0.5, 0.5, 0.2, 0.2);
objReportPrintClass.Print(ConfigurationSettings.AppSettings["PrinterName"], 1);
}
catch(Exception ex)
{
}
}
public ReportPrintClass(string _DataSourceName, DataTable _DataSourceValue, string _ReportPath, double pagewidth, double pageheight, double leftmargin, double rightmargin, double topmargin, double bottommargin)
{
this.pageWidth = pagewidth;
this.pageHeight = pageheight;
this.leftMargin = leftmargin;
this.rightMargin = rightmargin;
this.topMargin = topmargin;
this.bottomMargin = bottommargin;
LocalReport report = new LocalReport();
report.ReportPath = _ReportPath;
report.DataSources.Add(new ReportDataSource(_DataSourceName, _DataSourceValue));
Export(report);
m_currentPageIndex = 0;
}
public ReportPrintClass(string _DataSourceName, DataTable _DataSourceValue, string _ReportPath, ReportParameter[] arrParams, double pagewidth, double pageheight, double leftmargin, double rightmargin, double topmargin, double bottommargin)
{
this.pageWidth = pagewidth;
this.pageHeight = pageheight;
this.leftMargin = leftmargin;
this.rightMargin = rightmargin;
this.topMargin = topmargin;
this.bottomMargin = bottommargin;
LocalReport report = new LocalReport();
report.ReportPath = _ReportPath;
report.DataSources.Add(new ReportDataSource(_DataSourceName, _DataSourceValue));
report.SetParameters(arrParams);
Export(report);
m_currentPageIndex = 0;
}
private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek)
{
Stream stream = new FileStream(name +
"." + fileNameExtension, FileMode.Create);
m_streams.Add(stream);
return stream;
}
private void Export(LocalReport report)
{
string deviceInfo =
"<deviceinfo>" +
" <outputformat>EMF</outputformat>" +
" <pagewidth>" + pageWidth + "in</pagewidth>" +
" <pageheight>" + pageHeight + "in</pageheight>" +
" <margintop>" + topMargin + "in</margintop>" +
" <marginleft>" + leftMargin + "in</marginleft>" +
" <marginright>" + rightMargin + "in</marginright>" +
" <marginbottom>" + bottomMargin + "in</marginbottom>" +
"</deviceinfo>";
Warning[] warnings;
m_streams = new List<stream>();
try
{
report.Render("Image", deviceInfo, CreateStream, out warnings);
}
catch (LocalProcessingException ex)
{
}
foreach (Stream stream in m_streams)
stream.Position = 0;
}
private void PrintPage(object sender, PrintPageEventArgs ev)
{
Metafile pageImage = new
Metafile(m_streams[m_currentPageIndex]);
ev.Graphics.DrawImage(pageImage, ev.PageBounds);
m_currentPageIndex++;
ev.HasMorePages = (m_currentPageIndex < m_streams.Count);
}
public void Print(string printerName, Int16 noCopy)
{
if (m_streams == null || m_streams.Count == 0)
return;
PrintDocument printDoc = new PrintDocument();
printDoc.PrinterSettings.Copies = noCopy;
printDoc.PrinterSettings.PrinterName = printerName;
if (!printDoc.PrinterSettings.IsValid)
{
}
printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
try
{
printDoc.Print();
}
catch (Exception ex)
{
}
}
public void Dispose()
{
{
foreach (Stream stream in m_streams)
stream.Close();
m_streams = null;
}
}
}
}</stream></productdetails>