none
Error trying to export to pdf and word, and print when subreport as imagem from database RRS feed

  • Question

  • I am get a this error
    Exception Details: System.ArgumentException: Parameter is not valid.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

    Stack Trace:


    [ArgumentException: Parameter is not valid.]
       System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData) +1144615
       System.Drawing.Image.FromStream(Stream stream) +8
       Microsoft.ReportingServices.Rendering.WordRenderer.PictureDescriptor.InitImage(Byte[] aImgData, Byte[] aHash, Int32 imgIndex) +3778

    [LocalProcessingException: An error occurred during local report processing.]
       Microsoft.Reporting.WebForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, PageCountMode pageCountMode, CreateAndRegisterStream createStreamCallback, Warning[]& warnings) +606
       Microsoft.Reporting.WebForms.LocalModeSession.RenderReport(String format, Boolean allowInternalRenderers, String deviceInfo, NameValueCollection additionalParams, Boolean cacheSecondaryStreamsForHtml, String& mimeType, String& fileNameExtension) +277
       Microsoft.Reporting.WebForms.ExportOperation.PerformOperation(NameValueCollection urlQuery, HttpResponse response) +292
       Microsoft.Reporting.WebForms.HttpHandler.ProcessRequest(HttpContext context) +233
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75


    I have a report with a list/table where one row has a subreport. In this subreport I have a table where one of the columns has jpg imagem from the database.
    The error only appear if I try to print, export to word and pfd (work only with excel).
    I dont get the error when I remove the image from the column in the subreport.

    Any ideia why this happens?

    Wednesday, July 14, 2010 8:28 PM

All replies

  • Hi Nuno,

    This sounds like it could be a bug in the product. Please file an issue at http://connect.microsoft.com and it will be routed to the product developoment team.


    Brad Syputa, Microsoft Reporting Services This posting is provided "AS IS" with no warranties.
    Wednesday, July 14, 2010 8:33 PM
  • possibly is the size of the images. I moved into a Thumbnail and began to work well

    Wednesday, July 14, 2010 8:39 PM
  • Hi........NunoCruz

                 If you want to display image from database to your rdlc file then you have to use image control for that purticular field.

                 For that just put rectangle in table column in which you want to display image and then in rectangle put image control in it

                and then drag and drop image field in to it.

                Now you and render pdf or excel file from reporviewer by programmatically also.

                Use the following code to generate file from reportviewer.

     //Page settings for PDF File.
            string mimeType;
            string encoding;
            string extension;
            string deviceInfo =
           "<DeviceInfo>" +
           " <OutputFormat>PDF</OutputFormat>" +
           " <PageWidth>8.5in</PageWidth>" +
           " <PageHeight>10.5in</PageHeight>" +
           " <MarginTop>0.05in</MarginTop>" +
           " <MarginLeft>0.05in</MarginLeft>" +
           " <MarginRight>0.05in</MarginRight>" +
           " <MarginBottom>0.05in</MarginBottom>" +
           "</DeviceInfo>";
    
            string[] streamids;
            Microsoft.Reporting.WinForms.Warning[] warnings;
    
            //Gives byte[] of Generated pdf file.
            byte[] bytes = reportViewer2.LocalReport.Render("PDF", deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings);
    
            FileStream fs = new FileStream("D:\abc.pdf",FileMode.Create,FileAccess.Write)
            fs.Write(bytes,0,(int)bytes.Length);
            fs.Close();
            
    If the above solution solve your problem then mark it as answer
    Friday, July 30, 2010 11:46 AM