0

I want to use justify feature in rdlc but it doesn't support. There have been algorithm writers in this problem, but when I get the output, I get results again (not justify).

I hope I can get a solution to this problem. Thanks a lot ..

teresa
  • 1
  • 3

1 Answers1

0

try this:

  1. add this function to report propertise in tab Code:

    Function GetText(text As String, width As Integer) As String
         Dim palabras As String() = text.Split(" "c)
         Dim sb1 As New System.Text.StringBuilder()
         Dim sb2 As New System.Text.StringBuilder()
         Dim length As Integer = palabras.Length
         Dim resultado As New System.Collections.Generic.List(Of String)()
         Dim i As Integer = 0
         While i < length
             sb1.AppendFormat("{0} ", palabras(i))
             If sb1.ToString().Length > width Then
                 resultado.Add(sb2.ToString())
                 sb1 = New System.Text.StringBuilder()
                 sb2 = New System.Text.StringBuilder()
                 System.Math.Max(System.Threading.Interlocked.Decrement(i), i + 1)
             Else
                 sb2.AppendFormat("{0} ", palabras(i))
             End If
             System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
         End While
         resultado.Add(sb2.ToString())
    
         Dim resultado2 As New System.Collections.Generic.List(Of String)()
         Dim temp As String
    
         Dim index1 As Integer, index2 As Integer, salto As Integer
         Dim target As String
         Dim limite As Integer = resultado.Count     
         For Each item As String In resultado        
             target = " "
             temp = item.ToString().Trim()
             index1 = 0
             index2 = 0
             salto = 2
    
             If limite <= 1 Then
                 resultado2.Add(temp)
                 Exit For
             End If
             While temp.Length <= width
                 If temp.IndexOf(target, index2) < 0 Then
                     index1 = 0
                     index2 = 0
                     target = target + " "
                     System.Math.Max(System.Threading.Interlocked.Increment(salto), salto - 1)
                 End If
                 index1 = temp.IndexOf(target, index2)
                 temp = temp.Insert(temp.IndexOf(target, index2), " ")
    
                 index2 = index1 + salto
             End While
             System.Math.Max(System.Threading.Interlocked.Decrement(limite), limite + 1)
             resultado2.Add(temp)
         Next
    
         Dim builder As New System.Text.StringBuilder()
         For Each item As String In resultado2
             builder.Append(item).Append(chr(10))
        Next
         Return builder.ToString()
     End Function
    
  2. Call custom code in yout textbox:

=Code.GetText("longtext…",77)

i know you are using C# , but in rdlc you can write vb code only.

the VB code converted from C# in this original answer: https://stackoverflow.com/a/38235745/2713855

also you can use custom dll reference with C# code and then you need only to call the function in you textbox Adding Custom Assemblies

NajiMakhoul
  • 1,623
  • 2
  • 16
  • 30
  • Thank you for the answer. Unfortunately this code is not as successful as the microsoft word. The template is very important to me. So I will export the microsoft word and edit there. This time it does not fit on a single page in the word. I would like to thank microsoft's rdlc developers for not fixing this feature for years. and moreover they do not publish good examples describing rdlc features. Thank you ! – teresa Jul 03 '20 at 08:38
  • yes, you are right ... there is not official justify support from Microsoft for RDLC reports – NajiMakhoul Jul 03 '20 at 08:51