Copy & Paste to Visio / Word / PowerPoint

4 posts, 0 answers
  1. Manuel
    Manuel avatar
    32 posts
    Member since:
    Sep 2013

    Posted 26 Feb 2014 Link to this post

    I know I can export a RadDiagram as image using the ExportToImage method, this works fine but allows to paste a static image (bmp, jpg...).
    For my users it will be really useful to paste a set of shapes, in order to re-arrange them into PowerPoint (or change size, color...).

    This feature should be one-way only: I don't need to support the case of a user pasting from Office to the RadDiagram... Is it possible?

    Any idea?
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 03 Mar 2014 Link to this post

    Hello Manuel,

    RadDiagram uses serialization to implement its clipboard operations. This is why when a RadDiagramItem is copied, it is serialized and all its information is saved in a serialization string. This is why if you use the built-in copy/paste implementation of the RadDiagramItems, a paste into MSOffice application will produce an xml string.

    This is why the scenario you described does not work out of the box. However, you can implement a custom copy operation. If you use the RadDiagram CreateDiagramImage() method you can pass a Rect object describing a portion of the diagramming surface. The method will then create an image of the DiagramItems contained within the rectangle. You can then add the image to the clipboard manually so that  a paste operation into MSOffice application can paste an image.

    I attached a sample application demonstrating this approach. The custom Copy implementation is triggered on a button click. Please take a look at the solution and let me know if it can work for you.

    Regards,
    Tina Stancheva
    Telerik
  3. UI for WPF is Visual Studio 2017 Ready
  4. Manuel
    Manuel avatar
    32 posts
    Member since:
    Sep 2013

    Posted 03 Mar 2014 in reply to Tina Stancheva Link to this post

    Hello Tina,
    thank you for your response.
    Your sample is really similar to what I've already implemented: it works, but selected shapes are copied as a single image.
    If a user need to change labels / colors / shape positions, she need to use an image editing tool (i.e. Photoshop).

    I've attached a screenshot of a simple diagram built with your demo application.
    Here you can fine the expected result (on a Word document, but it will be nice to do the same also with PowerPoint and Excel).
    Hope this will clarify my requirements.

    Regards,
    Manuel
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 06 Mar 2014 Link to this post

    Hi Manuel,

    Thank you for elaborating on your scenario. Unfortunately RadDiagram cannot paste its items in MSOffice in the manner you described. RadDiagram can export its items in an image or save them in a serialization string. You can use both of these options to create a copy of an item and then paste it. However in order to manipulate shapes in an MSOffice application, these shapes should have a specific type recognizable inside MSOffice. This, however, is not a supported operation.

    Instead you can try and create an image for each selected shape individually and paste in MsOffice multiple images. However, as they will be handled as images and you will have little control over them in Word or PowerPoint.

    Regards,
    Tina Stancheva
    Telerik

    DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!

Back to Top