diff --git a/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object.sln b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object.sln new file mode 100644 index 000000000..bca5bcf0a --- /dev/null +++ b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object.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}") = "Add-different-document-format-as-OLE-object", "Add-different-document-format-as-OLE-object\Add-different-document-format-as-OLE-object.csproj", "{D3AF529E-DB54-4294-A876-DD42E1E472D0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D3AF529E-DB54-4294-A876-DD42E1E472D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D3AF529E-DB54-4294-A876-DD42E1E472D0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D3AF529E-DB54-4294-A876-DD42E1E472D0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D3AF529E-DB54-4294-A876-DD42E1E472D0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {58137FF9-5AE1-4514-9929-3A8A7DA1DFEB} + EndGlobalSection +EndGlobal diff --git a/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Add-different-document-format-as-OLE-object.csproj b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Add-different-document-format-as-OLE-object.csproj new file mode 100644 index 000000000..c21da633a --- /dev/null +++ b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Add-different-document-format-as-OLE-object.csproj @@ -0,0 +1,43 @@ + + + + Exe + net8.0 + Add_different_document_format_as_OLE_object + + + + + + + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + + diff --git a/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/Adventure.docx b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/Adventure.docx new file mode 100644 index 000000000..e4b8b1137 Binary files /dev/null and b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/Adventure.docx differ diff --git a/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/Sample.pptx b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/Sample.pptx new file mode 100644 index 000000000..b0a1f2438 Binary files /dev/null and b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/Sample.pptx differ diff --git a/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/Template.pdf b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/Template.pdf new file mode 100644 index 000000000..ca822decb Binary files /dev/null and b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/Template.pdf differ diff --git a/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/Template.xlsx b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/Template.xlsx new file mode 100644 index 000000000..1059e098c Binary files /dev/null and b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/Template.xlsx differ diff --git a/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/excel.png b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/excel.png new file mode 100644 index 000000000..3a8cf5104 Binary files /dev/null and b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/excel.png differ diff --git a/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/pdf.png b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/pdf.png new file mode 100644 index 000000000..0682b3511 Binary files /dev/null and b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/pdf.png differ diff --git a/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/powerpoint.png b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/powerpoint.png new file mode 100644 index 000000000..23d2ae64d Binary files /dev/null and b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/powerpoint.png differ diff --git a/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/word.png b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/word.png new file mode 100644 index 000000000..8781cedb9 Binary files /dev/null and b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Data/word.png differ diff --git a/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Output/.gitkeep b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Program.cs b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Program.cs new file mode 100644 index 000000000..142f704b2 --- /dev/null +++ b/Paragraphs/Add-different-document-format-as-OLE-object/.NET/Add-different-document-format-as-OLE-object/Program.cs @@ -0,0 +1,57 @@ +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; +using System.IO; + +namespace Add_different_document_format_as_OLE_object +{ + class Program + { + static void Main(string[] args) + { + // Create a new Word document. + using (WordDocument document = new WordDocument()) + { + // Add a new section to the document. + IWSection section = document.AddSection(); + + // Add different types of documents as OLE objects. + AddOleObject(document, section, "Data/Template.pdf", "Data/pdf.png", OleObjectType.AdobeAcrobatDocument); + AddOleObject(document, section, "Data/Template.xlsx", "Data/excel.png", OleObjectType.ExcelWorksheet); + AddOleObject(document, section, "Data/Adventure.docx", "Data/word.png", OleObjectType.WordDocument); + AddOleObject(document, section, "Data/Sample.pptx", "Data/powerpoint.png", OleObjectType.PowerPointPresentation); + + // Save the Word document to a file. + using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite)) + { + document.Save(outputStream, FormatType.Docx); + } + } + } + + /// + /// Adds an OLE object to the Word document. + /// + private static void AddOleObject(WordDocument document, IWSection section, string filePath, string imagePath, OleObjectType oleType) + { + // Add a new paragraph to the section. + IWParagraph paragraph = section.AddParagraph(); + + // Open the file to be embedded as an OLE object. + using (FileStream fileStream = new FileStream(Path.GetFullPath(filePath), FileMode.Open)) + using (FileStream imageStream = new FileStream(Path.GetFullPath(imagePath), FileMode.Open, FileAccess.ReadWrite)) + { + // Load the image as a representation of the OLE object. + WPicture picture = new WPicture(document); + picture.LoadImage(imageStream); + + // Append the OLE object to the paragraph. + WOleObject oleObject = paragraph.AppendOleObject(fileStream, picture, oleType); + paragraph.AppendText("\n"); + + // Set the display size of the OLE object. + oleObject.OlePicture.Height = 80; + oleObject.OlePicture.Width = 100; + } + } + } +}