private int m_currentPageIndex; private IList<Stream> m_streams; private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek) { Stream stream = new MemoryStream(); m_streams.Add(stream); return stream; } // Export the given report as an EMF (Enhanced Metafile) file. private void Export(LocalReport report, bool isLandscape) { string deviceInfo = string.Empty; if (isLandscape) { deviceInfo = @"<DeviceInfo> <OutputFormat>EMF</OutputFormat> <PageWidth>11in</PageWidth> <PageHeight>8.5in</PageHeight> <MarginTop>0.25in</MarginTop> <MarginLeft>0.25in</MarginLeft> <MarginRight>0.25in</MarginRight> <MarginBottom>0.25in</MarginBottom> </DeviceInfo>"; } else { deviceInfo = @"<DeviceInfo> <OutputFormat>EMF</OutputFormat> <PageWidth>8.5in</PageWidth> <PageHeight>11in</PageHeight> <MarginTop>0.25in</MarginTop> <MarginLeft>0.25in</MarginLeft> <MarginRight>0.25in</MarginRight> <MarginBottom>0.25in</MarginBottom> </DeviceInfo>"; } Warning[] warnings; m_streams = new List<Stream>(); DSBillTableAdapters.DataTable1TableAdapter ds = new DSBillTableAdapters.DataTable1TableAdapter(); DSBillTableAdapters.DataTable2TableAdapter ds1 = new DSBillTableAdapters.DataTable2TableAdapter(); DSBillTableAdapters.NotificationTableAdapter ds3 = new DSBillTableAdapters.NotificationTableAdapter(); // Create Report DataSource ReportDataSource rds = new ReportDataSource("DataSet1"); ReportDataSource rds2 = new ReportDataSource("DataSet2"); ReportDataSource rds3 = new ReportDataSource("DataSet3"); rds.Value = ds.GetData(Convert.ToInt64(Request.QueryString["SaleId"])); rds2.Value = ds1.GetData(Convert.ToInt64(Request.QueryString["SaleId"])); rds3.Value = ds3.GetData(); ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(rds); ReportViewer1.LocalReport.DataSources.Add(rds2); ReportViewer1.LocalReport.DataSources.Add(rds3); report.Render("Image", deviceInfo, CreateStream, out warnings); foreach (Stream stream in m_streams) stream.Position = 0; Print(); } private void Print() { PrinterSettings settings = new PrinterSettings(); //set printer settings string printerName = settings.PrinterName; //use default printer name if (m_streams == null || m_streams.Count == 0) return; PrintDocument printDoc = new PrintDocument(); printDoc.PrinterSettings.PrinterName = printerName; if (!printDoc.PrinterSettings.IsValid) { string msg = String.Format( "Can't find printer \"{0}\".", printerName); MessageBox.Show(msg, "Print Error"); return; } printDoc.PrintPage += new PrintPageEventHandler(PrintPage); printDoc.Print(); foreach (Stream stream in m_streams) { stream.Dispose(); } } 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); } Do anyone has answer for this? If yes then plz reply
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)