How to write horizontally in SSRS (rotate text)

I found an interesting article on how to do this. It also works outside tables.

I needed to rotate the text with a custom color such as #0b4373 so I modified a few lines

to View similar code click here
 Function LoadImage(ByVal sImageText As String, ByVal sImageTextMax As String, ByVal color As String)
        ' For versions prior to R2 add reference System.Drawing
        sImageTextMax = sImageTextMax.PadRight(40)
        Dim iFontSize As Integer = 9 '//Change this as needed

        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("Garamond", iFontSize, System.Drawing.FontStyle.Bold, 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(sImageTextMax, MyFont).Width
        iHeight = MyGraphics.MeasureString(sImageTextMax, MyFont).Height '// Create the bmpImage again with the correct size for the text and font.
        'bmpImage = New Drawing.Bitmap(bmpImage, New Drawing.Size(iWidth, iHeight))
        bmpImage = New Drawing.Bitmap(bmpImage, New Drawing.Size(iHeight, iWidth)) '// Add the colors to the new bitmap.
        MyGraphics = Drawing.Graphics.FromImage(bmpImage)
        MyGraphics.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
        MyGraphics.TranslateTransform(0, iWidth)
        MyGraphics.DrawString(sImageText, MyFont, New Drawing.SolidBrush(Drawing.Color.White), 0, 0)
        Dim stream As IO.MemoryStream = New IO.MemoryStream
        Dim bitmapBytes As Byte() 'Create bitmap
        bmpImage.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg)
        bitmapBytes = stream.ToArray
        Return bitmapBytes
    End Function

No Comments Yet.

Leave a reply

You must be logged in to post a comment.