īy executing the program, you will get the output PDF document as follows. If (ImageFormat.Emf) Thenĭim imgFile As FileStream = New FileStream( "Output.png", FileMode.OpenOrCreate, FileAccess.ReadWrite)ĭim imageStream As FileStream = New FileStream( "Output.png", FileMode.Open, FileAccess.ReadWrite)Ī complete working example in C# can be downloaded from the sample. 'Iterates through the child elements of a paragraphįor Each item As ParagraphItem In paragraph.ChildEntitiesĭim picture As WPicture = CType (item, WPicture)ĭim image As Image = Image.FromStream( New MemoryStream(picture.ImageBytes)) 'Iterates through the paragraphs of the textbodyįor Each paragraph As WParagraph In textbody.Paragraphs Private Sub ConvertEMFToPNG( ByVal wordDocument As WordDocument)ĭim textbody As WTextBody = wordDocument.Sections(0).Body Include the following namespace in the Program.cs file.Install the NuGet package as a reference to your.Create a new C# console application project in.
To convert and replace EMF image in word document to PNG of the same size using C#
To preserve the expected images in the PDF, we suggest converting the metafile image formats to bitmap image formats (JPEG or PNG) and then performing Word to PDF conversion. Internally, if the Word document contains metafile images (.wmf” or *.emf”), Essential DocIO preserves those images as RedX images with the same size as the original metafile images during Word to PDF or Image conversions to avoid pagination issues. NET Core targeting applications, metafile images (.wmf and *.emf) have some limitations. NET Word library used to create, read, and edit Word documents programmatically without Microsoft Word or interop dependencies.