Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. ReportViewer LocalReport does not render correctly

ReportViewer LocalReport does not render correctly

Scheduled Pinned Locked Moved ASP.NET
graphicsperformancehelpquestion
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member 4382232
    wrote on last edited by
    #1

    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); }

    P M 3 Replies Last reply
    0
    • M Member 4382232

      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); }

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      Have you solved this?

      "The clue train passed his station without stopping." - John Simmons / outlaw programmer

      M 1 Reply Last reply
      0
      • P Paul Conrad

        Have you solved this?

        "The clue train passed his station without stopping." - John Simmons / outlaw programmer

        M Offline
        M Offline
        Member 4382232
        wrote on last edited by
        #3

        No, I wish I had!

        1 Reply Last reply
        0
        • M Member 4382232

          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); }

          M Offline
          M Offline
          Member 4382232
          wrote on last edited by
          #4

          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

          M 1 Reply Last reply
          0
          • M Member 4382232

            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

            M Offline
            M Offline
            Member 4382232
            wrote on last edited by
            #5

            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>";

            M 1 Reply Last reply
            0
            • M Member 4382232

              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>";

              M Offline
              M Offline
              Member 4382232
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              • M Member 4382232

                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); }

                M Offline
                M Offline
                Member 4382232
                wrote on last edited by
                #7

                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

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups