This is a migrated thread and some comments may be shown as answers.

Copy & Paste to Visio / Word / PowerPoint

3 Answers 123 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Manuel
Top achievements
Rank 1
Manuel asked on 26 Feb 2014, 11:44 AM
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?

3 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 03 Mar 2014, 09:59 AM
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
0
Manuel
Top achievements
Rank 1
answered on 03 Mar 2014, 11:11 AM
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
0
Tina Stancheva
Telerik team
answered on 06 Mar 2014, 10:20 AM
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!

Tags
Diagram
Asked by
Manuel
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Manuel
Top achievements
Rank 1
Share this question
or