Options

Report Text Mirror or Rotate

stonystony Member Posts: 122
edited 2015-05-12 in NAV Three Tier
Hallo,

is it possible to rotate 180 degrees a text in RDLC.

thanks
stony

Comments

  • Options
    yukonyukon Member Posts: 361
    Hi,

    You can rotate the text this director ("Horizontal","Vertical","Rotate270") by using "WritingMode" property of TextBox. Set Text Box Orientation (Report Builder and SSRS)https://msdn.microsoft.com/en-us/ee633659.aspx. In order to get your requirement you need to draw image at your report instead of using standard.

    Here is Draw the String Image base on your requirement (Mirror)
        Function DrawText(ByVal sImageText As String, ByVal sFont As String, ByVal iFontSize As Integer, ByVal iFontStyle As Integer)
            sImageText = sImageText.PadRight(40)
            Dim bmpImage As New Drawing.Bitmap(1, 1)
            Dim iWidth As Integer = 0
            Dim iHeight As Integer = 0
    
            '// Create the Font object for the image text drawing.
            Dim MyFont As New Drawing.Font(sFont, iFontSize, iFontStyle, System.Drawing.GraphicsUnit.Point)
            '// Create a graphics object to measure the text's width and height.
            'Graphics(MyGraphics = Graphics.FromImage(bmpImage))
            Dim MyGraphics As Drawing.Graphics = Drawing.Graphics.FromImage(bmpImage)
            '// This is where the bitmap size is determined.
            iWidth = MyGraphics.MeasureString(sImageText, MyFont).Width
            iHeight = MyGraphics.MeasureString(sImageText, MyFont).Height
    
            '// Create the bmpImage again with the correct size for the text and font.
            'Make Horizontal
            bmpImage = New Drawing.Bitmap(bmpImage, New Drawing.Size(iWidth, iHeight))
            ''Make Vertical
            'bmpImage = New Drawing.Bitmap(bmpImage, New Drawing.Size(iHeight, iWidth))
    
            '// Add the colors to the new bitmap.
            MyGraphics = Drawing.Graphics.FromImage(bmpImage)
            MyGraphics.Clear(Drawing.Color.White)
            MyGraphics.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
    
            ''Here is original code
            'MyGraphics.TranslateTransform(0, iWidth)
            'MyGraphics.RotateTransform(270)
    
            MyGraphics.DrawString(sImageText, MyFont, New Drawing.SolidBrush(Drawing.Color.Black), 0, 0)
            MyGraphics.Flush()
            Dim stream As IO.MemoryStream = New IO.MemoryStream
            Dim bitmapBytes As Byte()
            'Create bitmap
            'Rotating the image
            'RotateFlipType.RotateNoneFlipY = 6
            bmpImage.RotateFlip(6)
    
            bmpImage.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg)
            bitmapBytes = stream.ToArray
            stream.Close()
            bmpImage.Dispose()
            Return bitmapBytes
    
        End Function
    

    1. Copy above function and past it at your report custom code.
    2. Add (System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) assemblies at report references.
    3. Add image to your report.
    4. Use below code at your Image's Value properties. And Image Source must be "Database".
    ''DrawText(YourText,FontName,FontSize,FontStyle)
    =code.DrawText("Hello World","Arial",10,0)
    

    You will be see below sample after you work above step.



    Here is original link http://www.sqljason.com/2011/01/rotate-text-in-ssrs.html to show vertical drawing for older SSRS version. Credit to "JASON THOMAS"


    Regards,
    Yukon
    Make Simple & Easy
Sign In or Register to comment.