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. Image for the cookie policy date

export MetafileNode object to MS WORD 2007

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.



7 Replies

PK Punith Kumar July 11, 2008 05:57 AM UTC

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. J.Nagarajan Syncfusion Team July 11, 2008 11:31 AM UTC

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,



PK Punith Kumar July 14, 2008 10:02 AM UTC

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. J.Nagarajan Syncfusion Team July 14, 2008 02:07 PM UTC

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. J.Nagarajan Syncfusion Team July 14, 2008 02:09 PM UTC

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



PK Punith Kumar July 16, 2008 01:38 AM UTC

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. J.Nagarajan Syncfusion Team July 16, 2008 12:48 PM UTC

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


Loader.
Live Chat Icon For mobile
Up arrow icon