Click here to Skip to main content
14,875,846 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to show the report by using .rdlc file in mvc C#. When i click to show the report it shown me some text on the place of designing section including textboxes color etc.

below is the example of my error when i generate the report.
%PDF-1.3 1 0 obj [/PDF /Text /ImageB /ImageC /ImageI] endobj 3 0 obj << /Length 96 /Filter /FlateDecode >> stream X ��*T06�3P04�P034�L�A��T�p�<^�@^� 0Qbn���@�@���H(��Se�If&8��3�4ga`�aÌĦ% �upYd���,� endstream endobj 2 0 obj << /Type /Page /Parent 4 0 R /MediaBox [0 0 684.0 792.0] /Contents 3 0 R /Resources << /ProcSet 1 0 R /XObject << >> /Font << >> >> >> endobj 4 0 obj << /Type /Pages /Kids [ 2 0 R ] /Count 1 >> endobj 5 0 obj << /Type /Catalog /Pages 4 0 R >> endobj 6 0 obj << /Title /Author <> /Subject <> /Creator (Microsoft Reporting Services 11.0.0.0) /Producer (Microsoft Reporting Services PDF Rendering Extension 11.0.0.0) /CreationDate (D:20210302120606+05'30') >> endobj xref 0 7 0000000000 65535 f 0000000010 00000 n 0000000237 00000 n 0000000065 00000 n 0000000390 00000 n 0000000452 00000 n 0000000504 00000 n trailer << /Size 7 /Root 5 0 R /Info 6 0 R >> startxref 778 %%EOF


What I have tried:

Here is the function which is called when I clicked on the generate report button.

public ActionResult GenerateReport(string ReportName)
       {
           LocalReport localReport = new LocalReport();
           localReport.ReportPath = Server.MapPath("~/Areas/RemoteAnalysis/Report1.rdlc");
           List<clsReport> lstOverallData = new List<clsReport>();

           using (DBClass context = new DBClass())
           {
               context.AddParameter("@FileID", Convert.ToInt32(Session["FileID"]));
               context.AddParameter("@UserID", Session["UserName"]);
               DataTable dtReportData = context.getData("GetRouteDetailForReport", CommandType.StoredProcedure);
               if (dtReportData.Rows.Count > 0)
               {
                   foreach (DataRow dr in dtReportData.Rows)
                   {
                       try
                       {
                           lstOverallData.Add(new clsReport
                           {
                               FileID = Convert.ToInt32(dr["Fileid"]),
                               PlantID = Convert.ToString(dr["PlantID"]),
                               PlantName = Convert.ToString(dr["PlantName"]),
                               AreaID = Convert.ToString(dr["AreaID"]),
                               AreaName = Convert.ToString(dr["AreaName"]),
                               TrainID = Convert.ToString(dr["TrainID"]),
                               TrainName = Convert.ToString(dr["TrainName"]),
                               MachineID = Convert.ToString(dr["MachineID"]),
                               MachineName = Convert.ToString(dr["MachineName"]),
                               PointID = Convert.ToString(dr["PointID"]),
                               PointName = Convert.ToString(dr["PointName"]),
                               AalrmID = Convert.ToInt32(dr["PointAlarmID"]),
                               AlarmName = Convert.ToString(dr["AlarmName"]),
                               HighValue = Convert.ToDouble(dr["HighValue"]),
                               LowValue = Convert.ToDouble(dr["LowValue"]),
                               MeasurementTime = Convert.ToDateTime("2018-04-17 14:44:02.293"),
                               OverallChnlA = Convert.ToDouble(dr["OverallValueChnlA"]),
                               UnitChnlA = Convert.ToString(dr["OverallUnitChnlA"]),
                               OverallChnlB = Convert.ToDouble(dr["OverallValueChnlB"]),
                               UnitChnlB = Convert.ToString(dr["OverallUnitChnlB"]),
                               DataID = Convert.ToInt32(dr["DataID"])
                           });
                       }
                       catch (Exception ex)
                       {
                           throw ex;
                       }
                   }

               }
           }
           ReportDataSource reportDataSource = new ReportDataSource("dsOverall", lstOverallData);


           localReport.DataSources.Add(reportDataSource);
           localReport.Refresh();
           string reportType = "PDF";
           string mimeType;
           string encoding;
           string fileNameExtension;

           string deviceInfo = "<DeviceInfo>" +
               "  <OutputFormat>PDF</OutputFormat>" +
               "<PageTitle> Report</PageTitle>" +
               "  <PageWidth>9.5in</PageWidth>" +
               "  <PageHeight>11in</PageHeight>" +
               "  <MarginTop>0.5in</MarginTop>" +
               "  <MarginLeft>0.5in</MarginLeft>" +
               "  <MarginRight>0.5in</MarginRight>" +
               "  <MarginBottom>0.5in</MarginBottom>" +
               "</DeviceInfo>";
           Warning[] warnings;
           string[] streams;
           byte[] renderedBytes;
           //Render the report
           renderedBytes = localReport.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);

           ViewBag.Title = "Alarm Report";
           return File(renderedBytes, mimeType);

       }
Posted
Comments
Member 14743579 2-Mar-21 6:26am
   
I think my pdf page is not working perfectly in the above code anyone have a solution about it please tell me.
Gerry Schmitz 2-Mar-21 13:58pm
   
That's a pdf file (contents); not an "error".
Member 14743579 3-Mar-21 0:10am
   
I know about it, How to solve this issue and get a correct form of data in pdf format. If you have any idea about please tell me..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900