We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

export MetafileNode object to MS WORD 2007

Thread ID:

Created:

Updated:

Platform:

Replies:

75078 Jul 11,2008 01:27 AM Jul 16,2008 08:48 AM Windows Forms 7
loading
Tags: Diagram
Punith Kumar
Asked On July 11, 2008 01:27 AM

Hi everybody,

My task is to insert an image to a word document. I know that an image file can be inserted to word using AddPicture Method. But I dont have the image file. What I have is a MetafileNode Object and I can get the Image from MetafileNode.Image. I want to insert that image to MS WORD.

How can I do that using C# & VSTO.

Plese help.



Punith Kumar
Replied On July 11, 2008 01:57 AM

Sorry.
There was an eeror in the message.
I cant get the Image object from the MetafileNode object. What I can get from this is Metafile object.
Any Ideas???

>Hi everybody,

My task is to insert an image to a word document. I know that an image file can be inserted to word using AddPicture Method. But I dont have the image file. What I have is a MetafileNode Object and I can get the Image from MetafileNode.Image. I want to insert that image to MS WORD.

How can I do that using C# & VSTO.

Plese help.





J.Nagarajan [Syncfusion]
Replied On July 11, 2008 07:31 AM

Hi Punith ,

Thanks for your interest in Syncfusion products. Our Essential Diagram allows you to export the diagram to the Word document. You have to save the diagram in metafile format and you can export this image to the word document using our Essential DocIo. Please refer to the following code snippet.

System.Drawing.Image diagramimage = new Bitmap(1, 1, PixelFormat.Format24bppRgb);
Graphics grfx = Graphics.FromImage(diagramimage);
IntPtr hdc = grfx.GetHdc();
Metafile emf = new Metafile(hdc, EmfType.EmfOnly);
Graphics emfgrfx = Graphics.FromImage(emf);
this.diagram.View.ExportDiagramToGraphics(emfgrfx);
grfx.ReleaseHdc(hdc);
grfx.Dispose();
emfgrfx.Dispose();
diagramimage.Dispose();
WordDocument document = new WordDocument();
//Adding a new section to the document.
IWSection section = document.AddSection();
//Adding a paragraph to the section
IWParagraph paragraph = section.AddParagraph();
WPicture mImage = (WPicture)paragraph.AppendPicture(emf);
document.Save("Sample.doc", Syncfusion.DocIO.FormatType.Doc);
System.Diagnostics.Process.Start("Sample.doc");

Please refer to the attached sample that demonstrates this completely.

http://www.syncfusion.com/Product/uploads/ExportToWord_ea8f81ee.zip

Please let me know if this helps.

Regards,


Punith Kumar
Replied On July 14, 2008 06:02 AM

Thanks for the reply Mr.Nagarajan.

What I have is Syncfusion Essential Studio 6.2.0.40, Is it possible to use DocIo with this suite?

>Hi Punith ,

Thanks for your interest in Syncfusion products. Our Essential Diagram allows you to export the diagram to the Word document. You have to save the diagram in metafile format and you can export this image to the word document using our Essential DocIo. Please refer to the following code snippet.

System.Drawing.Image diagramimage = new Bitmap(1, 1, PixelFormat.Format24bppRgb);
Graphics grfx = Graphics.FromImage(diagramimage);
IntPtr hdc = grfx.GetHdc();
Metafile emf = new Metafile(hdc, EmfType.EmfOnly);
Graphics emfgrfx = Graphics.FromImage(emf);
this.diagram.View.ExportDiagramToGraphics(emfgrfx);
grfx.ReleaseHdc(hdc);
grfx.Dispose();
emfgrfx.Dispose();
diagramimage.Dispose();
WordDocument document = new WordDocument();
//Adding a new section to the document.
IWSection section = document.AddSection();
//Adding a paragraph to the section
IWParagraph paragraph = section.AddParagraph();
WPicture mImage = (WPicture)paragraph.AppendPicture(emf);
document.Save("Sample.doc", Syncfusion.DocIO.FormatType.Doc);
System.Diagnostics.Process.Start("Sample.doc");

Please refer to the attached sample that demonstrates this completely.

http://www.syncfusion.com/Product/uploads/ExportToWord_ea8f81ee.zip

Please let me know if this helps.

Regards,




J.Nagarajan [Syncfusion]
Replied On July 14, 2008 10:07 AM

Hi Punith ,

You need the following assemblies to run the DocIo application.

Syncfusion.dls.Base
Syncfusion.docio.base

Please check these assemblies are installed in your Precompiledassemblies folder(C:\Program Files\Syncfusion\Essential Studio\6.3.0.25\precompiledassemblies\6.3.0.25\2.0). If these assemblies are not installed then you need to get the license of DocIo product to run the DocIo application. Please contact your Syncfusion Sales Representative or e-mail salessupport@syncfusion.com to get the license of DocIo in v6.2.0.40.

Please let me know if you have any other questions.

Regards,
Nagaraj




J.Nagarajan [Syncfusion]
Replied On July 14, 2008 10:09 AM

Hi Punith,

Sorry for posting wrong path for Precompiledassemblies folder. Please check these assemblies are installed in your Precompiledassemblies folder(C:\Program Files\Syncfusion\Essential Studio\6.2.0.40\precompiledassemblies\6.2.0.40\2.0).

Thanks,
Nagaraj


Punith Kumar
Replied On July 15, 2008 09:38 PM

Hi Mr.Nagarajan,
I couldnt find the libraries you specified.
Do I have to buy seperate licence of DocIo?
Can you send me the details?

>Hi Punith,

Sorry for posting wrong path for Precompiledassemblies folder. Please check these assemblies are installed in your Precompiledassemblies folder(C:\Program Files\Syncfusion\Essential Studio\6.2.0.40\precompiledassemblies\6.2.0.40\2.0).

Thanks,
Nagaraj




J.Nagarajan [Syncfusion]
Replied On July 16, 2008 08:48 AM

Hi Punith ,

Yes, you need DocIo licence to run the DocIo application. Please contact your Syncfusion Sales Representative or e-mail salessupport@syncfusion.com to get the license of DocIo in v6.2.0.40. Please let me know if you have any other questions.

Regards,
Nagaraj


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;