ReportViewer LocalReport does not render correctly
-
Hi, I created a printer friendly page which renders the report as an "image" into a memory stream. On the printer friendly page I have an image button which displays the image. Some of the columns did not render and not all rows are included. Can anyone assist me with this issue. Also, how do I reference the memory stream without saving it in session (see *****************) Thanks Code: protected void btPrint_Click1(object sender, EventArgs e) { Warning[] warnings; string[] streamids; string mimeType; string encoding; string extension; byte[] bytes = ReportViewer.LocalReport.Render("Image", null, out mimeType, out encoding, out extension, out streamids, out warnings); MemoryStream s = new MemoryStream(bytes); Session["MemStream"] = s; ***************** Response.Redirect("PrinterFriendly.aspx"); } PrinterFriendly.aspx Imager.aspx.cs: protected void Page_Load(object sender, EventArgs e) { Response.ContentType = "image/gif"; System.Drawing.Image img = System.Drawing.Image.FromStream(Session["MemStream"]); ****** img.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif); }
-
Hi, I created a printer friendly page which renders the report as an "image" into a memory stream. On the printer friendly page I have an image button which displays the image. Some of the columns did not render and not all rows are included. Can anyone assist me with this issue. Also, how do I reference the memory stream without saving it in session (see *****************) Thanks Code: protected void btPrint_Click1(object sender, EventArgs e) { Warning[] warnings; string[] streamids; string mimeType; string encoding; string extension; byte[] bytes = ReportViewer.LocalReport.Render("Image", null, out mimeType, out encoding, out extension, out streamids, out warnings); MemoryStream s = new MemoryStream(bytes); Session["MemStream"] = s; ***************** Response.Redirect("PrinterFriendly.aspx"); } PrinterFriendly.aspx Imager.aspx.cs: protected void Page_Load(object sender, EventArgs e) { Response.ContentType = "image/gif"; System.Drawing.Image img = System.Drawing.Image.FromStream(Session["MemStream"]); ****** img.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif); }
Have you solved this?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
-
Have you solved this?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
No, I wish I had!
-
Hi, I created a printer friendly page which renders the report as an "image" into a memory stream. On the printer friendly page I have an image button which displays the image. Some of the columns did not render and not all rows are included. Can anyone assist me with this issue. Also, how do I reference the memory stream without saving it in session (see *****************) Thanks Code: protected void btPrint_Click1(object sender, EventArgs e) { Warning[] warnings; string[] streamids; string mimeType; string encoding; string extension; byte[] bytes = ReportViewer.LocalReport.Render("Image", null, out mimeType, out encoding, out extension, out streamids, out warnings); MemoryStream s = new MemoryStream(bytes); Session["MemStream"] = s; ***************** Response.Redirect("PrinterFriendly.aspx"); } PrinterFriendly.aspx Imager.aspx.cs: protected void Page_Load(object sender, EventArgs e) { Response.ContentType = "image/gif"; System.Drawing.Image img = System.Drawing.Image.FromStream(Session["MemStream"]); ****** img.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif); }
What I have added to the above code: string deviceInfo = "" + "EMF" + "10in" + "100in" + "0.0in" + "0.0in" + "0.0in" + "0.0in" + ""; The pagewidth in the rdlc is 8.5in but for some reason it cuts of when rendered. The pagewidth setting above solves the columns being cut off (and still fits on a portrait pagesetup. Now, if I increase the pageheight it also includes the entire report vertically, BUT how do I calculate what the correct height must be, what happens with the above code is that it includes all rows of data plus a number of empty pages to make up for the 100inches, which is not what I want. Another problem that comes from this settings is that the first page is blank and the report starts printing on the second page. please give ideas. Thanx
-
What I have added to the above code: string deviceInfo = "" + "EMF" + "10in" + "100in" + "0.0in" + "0.0in" + "0.0in" + "0.0in" + ""; The pagewidth in the rdlc is 8.5in but for some reason it cuts of when rendered. The pagewidth setting above solves the columns being cut off (and still fits on a portrait pagesetup. Now, if I increase the pageheight it also includes the entire report vertically, BUT how do I calculate what the correct height must be, what happens with the above code is that it includes all rows of data plus a number of empty pages to make up for the 100inches, which is not what I want. Another problem that comes from this settings is that the first page is blank and the report starts printing on the second page. please give ideas. Thanx
Sorry the code did not paste corectly: string deviceInfo = "<DeviceInfo>" + " <OutputFormat>EMF</OutputFormat>" + " <PageWidth>10in</PageWidth>" + " <PageHeight>100in</PageHeight>" + " <MarginTop>0.0in</MarginTop>" + " <MarginLeft>0.0in</MarginLeft>" + " <MarginRight>0.0in</MarginRight>" + " <MarginBottom>0.0in</MarginBottom>" + "</DeviceInfo>";
-
Sorry the code did not paste corectly: string deviceInfo = "<DeviceInfo>" + " <OutputFormat>EMF</OutputFormat>" + " <PageWidth>10in</PageWidth>" + " <PageHeight>100in</PageHeight>" + " <MarginTop>0.0in</MarginTop>" + " <MarginLeft>0.0in</MarginLeft>" + " <MarginRight>0.0in</MarginRight>" + " <MarginBottom>0.0in</MarginBottom>" + "</DeviceInfo>";
Hi, I have tried a different aproach: Every page is saved in the stream object. List consists of all pages. print_click(...) { m_streams = new List<Stream>(); ReportViewer.LocalReport.Render("Image", deviceInfo, CreateStream, out warnings); foreach (Stream stream in m_streams) stream.Position = 0; Session["MemStreamList"] = (List<Stream>)m_streams; Response.Redirect("PrinterFriendly.aspx"); } imager.aspx.cs: page_load(..) { Response.ContentType = "image/gif"; List<Stream> memList = new List<Stream>(); memList = Session["MemStreamList"]; for (int i = 1; i < memList.Count; i++) { System.Drawing.Image img = System.Drawing.Image.FromStream(memList[i]); } img.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif); } Problem is that now I only have the last page. Question: How do I create one image in response.outputstream for all images in list? Please help Thanx
-
Hi, I created a printer friendly page which renders the report as an "image" into a memory stream. On the printer friendly page I have an image button which displays the image. Some of the columns did not render and not all rows are included. Can anyone assist me with this issue. Also, how do I reference the memory stream without saving it in session (see *****************) Thanks Code: protected void btPrint_Click1(object sender, EventArgs e) { Warning[] warnings; string[] streamids; string mimeType; string encoding; string extension; byte[] bytes = ReportViewer.LocalReport.Render("Image", null, out mimeType, out encoding, out extension, out streamids, out warnings); MemoryStream s = new MemoryStream(bytes); Session["MemStream"] = s; ***************** Response.Redirect("PrinterFriendly.aspx"); } PrinterFriendly.aspx Imager.aspx.cs: protected void Page_Load(object sender, EventArgs e) { Response.ContentType = "image/gif"; System.Drawing.Image img = System.Drawing.Image.FromStream(Session["MemStream"]); ****** img.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif); }
Finally! I have used different sources to get my solutions, some of which I got from codeproject. Here goes: default.aspx.cs: protected void btPrint_Click(object sender, EventArgs e) { RenderReport(); Response.Redirect("PrinterFriendly.aspx"); } private void RenderReport() { Warning[] warnings; string deviceInfo = "<DeviceInfo>" + " <OutputFormat>EMF</OutputFormat>" + " <PageWidth>10in</PageWidth>" + " <PageHeight>13in</PageHeight>" + " <MarginTop>0.0in</MarginTop>" + " <MarginLeft>0.0in</MarginLeft>" + " <MarginRight>0.0in</MarginRight>" + " <MarginBottom>0.0in</MarginBottom>" + "</DeviceInfo>"; m_streams = new List<Stream>(); ReportViewer.LocalReport.Render("Image", deviceInfo, CreateStream, out warnings); Session["MemStreamList"] = (List<Stream>)m_streams; } private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek) { Guid newid = Guid.NewGuid(); Stream stream = new FileStream(name + newid + "." + fileNameExtension, FileMode.Create); m_streams.Add(stream); return stream; } printerfriendly.aspx.cs: protected void Page_Load(object sender, EventArgs e) { List<Stream> memList = (List<Stream>)Session["MemStreamList"]; for (int i = 0; i < memList.Count; i++) { string imgString = "<img src=\"MultipleImaging.aspx?Index=" + i + "\">"; this.Controls.Add(new LiteralControl(imgString)); } } multipleimaging.aspx.cs: protected void Page_Load(object sender, EventArgs e) { if ((Session["MemStreamList"] != null) && Session["MemStreamList"].GetType().Equals(typeof(List<Stream>))) { List<Stream> images = (List<Stream>)Session["MemStreamList"]; int index = Int32.Parse(Request.Params.Get(0).ToString()); if (images[index].Length > 0) { try