If the report is too wide, the image rendered by the reporting service is cut off
I render an image by using the Render method of the Reporting service, the format is IMAGE and the output extension is .tif. Everything is ok. But the result confuse me, if the report is too wide the image rendered is cut off and the content is center in the image, there are some blank around the content Can anybody show me some advices?
December 28th, 2010 1:48am

string devInfo = @"<DeviceInfo> <MarginLeft>0.1in</MarginLeft> <MarginTop>0.1in</MarginTop> <MarginRight>0.1in</MarginRight> <MarginBottom>0.1in</MarginBottom> <PageHeight>" + execInfoLoadReport.ReportPageSettings.PaperSize.Height * 0.0394 + @"in</PageHeight> <PageWidth>" + execInfoLoadReport.ReportPageSettings.PaperSize.Width * 0.0394 + @"in</PageWidth> <OutputFormat>PNG</OutputFormat> <Toolbar>False</Toolbar> </DeviceInfo>"; byte[] result = _reportExecution.Render(format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs); I found the way to cut the blank around the content in the image as above. In the DeviceInfo setting, you can do more. http://technet.microsoft.com/en-us/library/ms155373.aspx But The size in the ReportPageSettings is not the size of report body but the report page The size of the image is larger than what I want. Anything way to solve this ? Or how can I get the body size of the report not the page size?
Free Windows Admin Tool Kit Click here and download it now
December 28th, 2010 2:58am

Maybe this solution is not good enough. I know the report path, so I can serialize a Report instance from the report definition. Then I got the width and height of the report body. First : Generate Classes from the RDL Schema using the xsd Tool http://technet.microsoft.com/en-us/library/aa337455.aspx If you have installed the reporting server, the schema URL is as follow: http://<<Computer name>>/<<instance name>>/reportdefinition.xsd Second : Load a Report Definition from the Report Server http://technet.microsoft.com/en-us/library/aa337430.aspx now you got the class Report Third : Getting the width and height of the report body (Reporting Server 2008 R2) public ReportInfo GetReportInfo(string reportPath) { ReportInfo reportInfo = new ReportInfo(); try { Logger.LogInfo("Enter"); // Retrieve the report defintion from the report server byte[] bytes = _reportService.GetItemDefinition(reportPath); if (bytes != null) { System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(Report)); // Load the report bytes into a memory stream using (MemoryStream stream = new MemoryStream(bytes)) { // Deserialize the report stream to an instance of the Report class Report _report = (Report)serializer.Deserialize(stream); List<ItemsChoiceType118> _reportItems = new List<ItemsChoiceType118>(_report.ItemsElementName); int indexSections = _reportItems.IndexOf(ItemsChoiceType118.ReportSections); ReportSectionType section = ((ReportSectionsType)_report.Items[indexSections]).ReportSection[0]; List<ItemsChoiceType117> sectionItems = new List<ItemsChoiceType117>(section.ItemsElementName); reportInfo.BodyWidth = (string)section.Items[sectionItems.IndexOf(ItemsChoiceType117.Width)]; BodyType body = (BodyType)section.Items[sectionItems.IndexOf(ItemsChoiceType117.Body)]; foreach (object obj in body.Items) { if (obj.GetType() == typeof(string)) { reportInfo.BodyHeight = obj.ToString(); break; } } } } Logger.LogInfo("Exit"); } catch (Exception ex) { Logger.LogError("{0}", ex); } return reportInfo; } In the code above, the reportInfo.BodyWidth and reportInfo.BodyHeight are what I wanted. You can ignore the ReportInfo and Logger , they have nothing to do with this question.
December 30th, 2010 10:13pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics