Actually its possible to Justify text in SSRS report if you pass the value as HTML and use something to format the text into justify'ed html text before, in my case im using .NET C# to format the passed string to justified html text.
But before that we need to to configure our SSRS report to accept HTML for this we need to add a text box and create a placeholder.
to add a place holder click on the textbox until it lets you write text to it then right click and choose "Create placeholder..."
After you created the place holder you will be prompted to enter the properties of the placeholder, all you need to specify is Value and Markup type
be sure to select the Markup type as HTML and for the value specify the variable that will have the justified html text in our case lets call it transformedHtml.
Now we need to create a function that trasforms our string to justified HTML text
/// <summary>
///
/// </summary>
/// <param name="text">The text that we want to justify</param>
/// <param name="width">Justified text width in pixels</param>
/// <param name="useHtmlTagsForNewLines">if true returns the output as justified html if false returns the ouput as justified string</param>
/// <returns>Justified string</returns>
public string GetText(string text, int width, bool useHtmlTagsForNewLines = false)
{
var palabras = text.Split(' ');
var sb1 = new StringBuilder();
var sb2 = new StringBuilder();
var length = palabras.Length;
var resultado = new List<string>();
var graphics = Graphics.FromImage(new Bitmap(1, 1));
var font = new Font("Times New Roman", 11);
for (var i = 0; i < length; i++)
{
sb1.AppendFormat("{0} ", palabras[i]);
if (graphics.MeasureString(sb1.ToString(), font).Width > width)
{
resultado.Add(sb2.ToString());
sb1 = new StringBuilder();
sb2 = new StringBuilder();
i--;
}
else
{
sb2.AppendFormat("{0} ", palabras[i]);
}
}
resultado.Add(sb2.ToString());
var resultado2 = new List<string>();
string temp;
int index1, index2, salto;
string target;
var limite = resultado.Count;
foreach (var item in resultado)
{
target = " ";
temp = item.Trim();
index1 = 0; index2 = 0; salto = 2;
if (limite <= 1)
{
resultado2.Add(temp);
break;
}
while (graphics.MeasureString(temp, font).Width <= width)
{
if (temp.IndexOf(target, index2) < 0)
{
index1 = 0; index2 = 0;
target = target + " ";
salto++;
}
index1 = temp.IndexOf(target, index2);
temp = temp.Insert(temp.IndexOf(target, index2), " ");
index2 = index1 + salto;
}
limite--;
resultado2.Add(temp);
}
var res = string.Join(useHtmlTagsForNewLines ? "<br> " + Environment.NewLine : "\n", resultado2);
if (useHtmlTagsForNewLines)
res = $"<div>{res.Replace(" ", " ").Replace("<br> ", "<br>")}</div>";
return res;
}
By using this function we can transform any string to justified text and we can select if we want the output to be HTMl or simple string
then we can just call this method like
string text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
string transformedHtml = GetText(text, 350, true);
and we get the output as folows:
In C#
In SSRS
Now this example mainly shows how to get justified text if your passing the values from C# code to ssrs reports but you could acchieve this if you would make the same function in a stored procedure that formats any text the same way. Hope this helps someone.