diff --git a/Paragraphs/Replace-image-with-new-EMF/.NET/Replace-image-with-new-EMF.sln b/Paragraphs/Replace-image-with-new-EMF/.NET/Replace-image-with-new-EMF.sln new file mode 100644 index 000000000..16ff3afcd --- /dev/null +++ b/Paragraphs/Replace-image-with-new-EMF/.NET/Replace-image-with-new-EMF.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31911.196 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Replace-image-with-new-EMF", "Replace-image-with-new-EMF\Replace-image-with-new-EMF.csproj", "{C17B90BC-F559-456B-B189-90B53FF6CDD4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EF357FC6-E9E5-4E3C-B932-43F727BE1DE4} + EndGlobalSection +EndGlobal diff --git a/Paragraphs/Replace-image-with-new-EMF/.NET/Replace-image-with-new-EMF/Data/Input.docx b/Paragraphs/Replace-image-with-new-EMF/.NET/Replace-image-with-new-EMF/Data/Input.docx new file mode 100644 index 000000000..8370f0c55 Binary files /dev/null and b/Paragraphs/Replace-image-with-new-EMF/.NET/Replace-image-with-new-EMF/Data/Input.docx differ diff --git a/Paragraphs/Replace-image-with-new-EMF/.NET/Replace-image-with-new-EMF/Data/image.emf b/Paragraphs/Replace-image-with-new-EMF/.NET/Replace-image-with-new-EMF/Data/image.emf new file mode 100644 index 000000000..6a6fa24d7 Binary files /dev/null and b/Paragraphs/Replace-image-with-new-EMF/.NET/Replace-image-with-new-EMF/Data/image.emf differ diff --git a/Paragraphs/Replace-image-with-new-EMF/.NET/Replace-image-with-new-EMF/Output/.gitkeep b/Paragraphs/Replace-image-with-new-EMF/.NET/Replace-image-with-new-EMF/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Paragraphs/Replace-image-with-new-EMF/.NET/Replace-image-with-new-EMF/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Paragraphs/Replace-image-with-new-EMF/.NET/Replace-image-with-new-EMF/Program.cs b/Paragraphs/Replace-image-with-new-EMF/.NET/Replace-image-with-new-EMF/Program.cs new file mode 100644 index 000000000..f76d6abd2 --- /dev/null +++ b/Paragraphs/Replace-image-with-new-EMF/.NET/Replace-image-with-new-EMF/Program.cs @@ -0,0 +1,24 @@ +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; +using System.Collections.Generic; +using System.IO; + +using (WordDocument document = new WordDocument(Path.Combine(@"../../../Data/input.docx"), FormatType.Docx)) +{ + //Find picture in document + List pictures = document.FindAllItemsByProperty(EntityType.Picture, null, null); + + if (pictures != null) + { + //Iterate and replace image + foreach (Entity entity in pictures) + { + WPicture picture = entity as WPicture; + FileStream imageStream = new FileStream(@"../../../Data/Image.emf", FileMode.Open, FileAccess.ReadWrite); + picture.LoadImage(imageStream); + imageStream.Close(); + + } + } + document.Save(@"../../../Output/output.docx", FormatType.Docx); +} \ No newline at end of file diff --git a/Paragraphs/Replace-image-with-new-EMF/.NET/Replace-image-with-new-EMF/Replace-image-with-new-EMF.csproj b/Paragraphs/Replace-image-with-new-EMF/.NET/Replace-image-with-new-EMF/Replace-image-with-new-EMF.csproj new file mode 100644 index 000000000..ed86d75ed --- /dev/null +++ b/Paragraphs/Replace-image-with-new-EMF/.NET/Replace-image-with-new-EMF/Replace-image-with-new-EMF.csproj @@ -0,0 +1,22 @@ + + + + Exe + net8.0 + Replace_image_with_new_EMF + + + + + + + + + Always + + + Always + + + +