Rotated text in Telerik.Windows.Documents.Model.Table

4 posts, 0 answers
  1. Mladen
    Mladen avatar
    27 posts
    Member since:
    Nov 2012

    Posted 19 Nov 2013 Link to this post

    Hi, this is more RadDocument related question but I RichTextBox section is the closest place for the thread...

    I'm creating pdf file using RadDocument. I want to have Table with rotated text in a cells like the one shown in the picture.

    I cannot accomplish that. I've seen Span has Flow Direction but it is left to right and right to left;

    I've tried to get UIElement and put it in the cell but RotateTransform applied to this element does not have effect in the document (i.e element is nor rotated)

    Please tell me whether this can be accomplished (and how)..

    Thank you in advance,
    Mladen Nikolov
  2. Petya
    Admin
    Petya avatar
    975 posts

    Posted 21 Nov 2013 Link to this post

    Hello Mladen,

    Rotating text is not currently a supported concept in RadDocument. What I could suggest is to try using the InlineUIContainer document elements. You can place an UIElement (TextBlock, for example) in the container and setting RotateTransform in this case should work as expected.
    Button button = new Button() { Width = 100, Height = 30, Content="Button" };
     
    RotateTransform rotateTransform = new RotateTransform(90);
    button.RenderTransform = rotateTransform;
     
    InlineUIContainer container = new InlineUIContainer();
    container.UiElement = button;
     
    container.Height = 100;
    container.Width = 30;
     
    this.radRichTextBox.InsertInline(container);

    Please note that InlineUiContainers have some specifics, including the fact that they cannot be resized or copied. Additionally, when exporting a document containing InlineUIContainers to PDF they are taken a snapshot of and included as images.

    I hope this fits your needs!

    Regards,
    Petya
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
  4. Mladen
    Mladen avatar
    27 posts
    Member since:
    Nov 2012

    Posted 25 Nov 2013 Link to this post

    Hi, thank you for your reply!

    I'm trying the following code based on your example but it does not work (nothing appears in the cell):

    foreach (var signal in allOutPutSignals)
    {
        var label = new Label { Content = signal.Tag, Visibility = Visibility.Visible };
        label.RenderTransform = new RotateTransform() { Angle = 90 };
         
        var panel = new RotatePanel() {};
        panel.Children.Add(label);
     
        var inlineContainer = new InlineUIContainer();
        inlineContainer.UiElement = panel;
     
        var paragraph = new Paragraph();
        paragraph.Inlines.Add(inlineContainer);
     
        var labelCell = new TableCell() { TextAlignment = RadTextAlignment.Center, PreferredWidth = new TableWidthUnit(12), Borders = new TableCellBorders(new Telerik.Windows.Documents.Model.Border(1, BorderStyle.Single, Colors.Black)) };
        labelCell.Blocks.Add(paragraph);
        row.Cells.Add(labelCell);
     
    }

    Where rotate panel is something I found in another thread (about the possibilities for applying LayoutTransform):

    public class RotatePanel : Panel
        {
            protected override Size MeasureOverride(Size availableSize)
            {
                foreach (UIElement child in this.Children)
                {
                    child.Measure(availableSize);
                }
     
                double maxWidth = this.Children.MaxOrDefault(child => child.DesiredSize.Width, 0);
                double maxHeight = this.Children.MaxOrDefault(child => child.DesiredSize.Height, 0);
     
                return new Size(maxHeight, maxWidth);
            }
     
             
     
            protected override Size ArrangeOverride(Size finalSize)
            {
                foreach (UIElement child in this.Children)
                {
                    child.Arrange(new Rect(0, (finalSize.Height / 2) + (child.DesiredSize.Width / 2), child.DesiredSize.Width, child.DesiredSize.Height));
                }
     
                return finalSize;
            }
        }
    }
     
     
    internal static class IEnumerableExtensions
        {
            internal static double MaxOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, double> selector, double defaultValue)
            {
                if (source.Any<TSource>())
                    return source.Max<TSource>(selector);
     
                return defaultValue;
            }
        }

    However with or withaut RotatePanel it does not work. Do you have an idea what am i doing wrong?

    Best Regards
  5. Petya
    Admin
    Petya avatar
    975 posts

    Posted 27 Nov 2013 Link to this post

    Hi Mladen,

    Part of the specifics of InlineUIContainer I mentioned is that they need to have their size set when initialized. Otherwise the container is not shown in the document. Setting the Width and Height properties or using the constructor that takes Size as parameter should resolve the issue.

    Let us know if you have other comments or questions.

    Regards,
    Petya
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top