Print Map

3 posts, 0 answers
  1. Aurelio Righetti
    Aurelio Righetti avatar
    51 posts
    Member since:
    May 2009

    Posted 05 Aug 2012 Link to this post

    Hi, i need to print the RadMap on a Paper with format A0 (big dimension), it's possibile ?
    Actually for print the map use the code on the post:http://www.telerik.com/community/forums/wpf/map/print-copy.aspx
    it's work but the dimension of the map is the dimension on the screen resolution.

    Thanks
    Aurelio
  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 08 Aug 2012 Link to this post

    Hello Aurelio,

    Using this approach you can't create image with pixel size more than original control has. But you can temporary increase size of the RadMap control, print it, and then restore original size. For example:

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
     
        <telerik:RadMap Name="radMap"
                ZoomLevel="5"
                Center="25,45">
            <telerik:RadMap.Providers>
                <telerik:OpenStreetMapProvider />
            </telerik:RadMap.Providers>
            <telerik:InformationLayer Name="informationLayer">
            </telerik:InformationLayer>
        </telerik:RadMap>
             
        <StackPanel Grid.Column="1">
            <Button Click="ChangeSize">
                <TextBlock Text="Change size" />
            </Button>
                 
            <Button Click="CopyToClipboard">
                <TextBlock Text="Copy To Clipboard" />
            </Button>
     
            <Button Click="RestoreSize">
                <TextBlock Text="Restore size" />
            </Button>
        </StackPanel>
    </Grid>



    private double originalWidth;
    private double originalHeight;
     
    private void ChangeSize(object sender, RoutedEventArgs e)
    {
        originalWidth = this.radMap.Width;
        originalHeight = this.radMap.Height;
     
        this.radMap.Width = 2500;
        this.radMap.Height = 2500;
     
        this.radMap.InvalidateVisual();
    }
     
    private void ControlToClipboard(FrameworkElement obj)
    {
        Transform transform = obj.LayoutTransform;
        obj.LayoutTransform = null;
     
        Thickness margin = obj.Margin;
        obj.Margin = new Thickness(0, 0, margin.Right - margin.Left,
            margin.Bottom - margin.Top);
     
        Size size = new Size(obj.ActualWidth, obj.ActualHeight);
     
        obj.Measure(size);
        obj.Arrange(new Rect(size));
     
        RenderTargetBitmap bmp = new RenderTargetBitmap((int)obj.ActualWidth,
            (int)obj.ActualHeight, 96, 96, PixelFormats.Pbgra32);
        bmp.Render(obj);
     
        obj.LayoutTransform = transform;
        obj.Margin = margin;
     
        Clipboard.SetImage(bmp);
    }
     
    private void CopyToClipboard(object sender, RoutedEventArgs e)
    {
        this.ControlToClipboard(this.radMap);
    }
     
    private void RestoreSize(object sender, RoutedEventArgs e)
    {
        this.radMap.Width = originalWidth;
        this.radMap.Height = originalHeight;
     
        this.radMap.InvalidateVisual();
    }

    Greetings,
    Andrey Murzov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Aurelio Righetti
    Aurelio Righetti avatar
    51 posts
    Member since:
    May 2009

    Posted 08 Aug 2012 Link to this post

    Hi..Andrey...thanks for the solution it's is Ok...

    Aurelio
Back to Top