How To Center Image Reporting Services In Table
SSRS: Correct and Eye Align Images in a Table
Nathan Eccles, fifteen April 2014
SSRS is a great tool for creating reports, just it has some limitations. One such limitation is right or eye aligning images. By default images are placed at the top left of a cell, and will aggrandize from in that location based on the Display properties you set. In order to position a static image we can either resize the prison cell the image is in, or modify the padding settings.
But what happens when you lot want to right or heart marshal a dynamic prototype?
Following is a method which will help you to manage your image positioning.
Please note that unfortunately this does not appear to work for CRM online.
The idea we are implementing hither is that if we know how wide the image is, we can add padding to the left of the image to infinite it out beyond the jail cell. So if our jail cell is 5cm wide, and our paradigm is 2cm wide, we desire to add together 3cm of padding to the left of the image to right marshal it.
In my scenario I am as well using the "Fit Proportional" display belongings, which means my image will have been scaled to fit the space. Therefore in order to work out its electric current width, I need to work out its proportions, decide how much the epitome has been scaled down by, and and then get the width.
Please annotation that in order for this lawmaking to working you lot must add a reference to System.Drawing inside the report.
To practise this, open up Report Backdrop, so click References, then Add. Click the ellipses and under the .NET tab, find System.Cartoon and click OK twice.
Below is the code I am using to reach the desired result. I'll break information technology all down for you and so you can run across what each part is doing.
=CSTR(255 - (round((System.Cartoon.Image.FromStream(new Arrangement.IO.MemoryStream(CType(System.Catechumen.FromBase64String(Fields!Notes_documentbody.Value), Byte()))).Width*0.75) / ((System.Drawing.Image.FromStream(new System.IO.MemoryStream(CType(Organization.Convert.FromBase64String(Fields!Notes_documentbody.Value), Byte()))).Height*0.75)/62),0))) + "pt"
Fields!Notes_documentbody.Value – This indicates the epitome y'all are referring to. In my case that is a file stored in a Note record within Dynamics CRM 2013.
System.Convert.FromBase64String(<>) – This is used to parse the image from a string into a useable format. This may not exist necessary depending on your data source, however due to how Dynamics CRM 2013 stores images it is necessary for my instance.
new System.IO.MemoryStream(CType(<>, Byte())) – This is used to put the Paradigm string into a Retentivity Stream which can be used to create a .Cyberspace Image.
System.Drawing.Image.FromStream(<>) – This converts the Memory Stream into a .Net Image type which nosotros can get properties from.
<>.Width / <>.Pinnacle – This gets the Width or Height of the created .NET Epitome. Annotation that this is the Width or Height of the full size paradigm in pixels.
<>*0.75 – The padding of an prototype in SSRS is done using "pt"s. 1 pixel is 0.75 pts, so to get the width and top in pts we must multiply by 0.75.
(<>/62) – My cell height is 2.2cm, only I need this in pts in society to calculate the scale. 62 is the elevation of the cell I am adding the image to in pts (rounded to the nearest whole number). You tin utilise the online converter for CMs to Pts or Inches to Pts depending on what you need.
256 - round(<>) – My jail cell width is 9cm. 255 is this width converted to pts (rounded to the nearest whole number). Rounding is used as the terminal reply needs to exist a whole number.
CSTR(<>) + "pt" – Our final answer needs to be in string format followed by "pt" in lodge to be recognised as a valid padding value.
With a slight tweak to this code we can centre the image.
=CSTR(round((256 - (round((System.Drawing.Paradigm.FromStream(new Organisation.IO.MemoryStream(CType(System.Convert.FromBase64String(Fields!Notes_documentbody.Value), Byte()))).Width*0.75) / ((System.Cartoon.Image.FromStream(new System.IO.MemoryStream(CType(System.Convert.FromBase64String(Fields!Notes_documentbody.Value), Byte()))).Height*0.75)/62),0))) / 2, 0)) + "pt"
The but difference here is that we divide the final result past 2 so that it only pads the image to the centre instead of the right.
Below we can encounter the result of using no padding, padding to the centre, and padding to the right for dynamics images.
This concept could be used in a range of different situations to help manage dynamic images within SSRS reports and provide a more aesthetically pleasing interface for the users of your report.
How To Center Image Reporting Services In Table,
Source: https://blog.magnetismsolutions.com/blog/nathaneccles/2014/04/15/ssrs-right-and-centre-align-images-in-a-table
Posted by: greencomplew.blogspot.com
0 Response to "How To Center Image Reporting Services In Table"
Post a Comment