diff --git a/DocX.sln b/DocX.sln index bceb4913..13b49600 100644 --- a/DocX.sln +++ b/DocX.sln @@ -57,7 +57,8 @@ Global {3EA73F1C-9E0B-4ED5-B04B-6C043D14D1AA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {3EA73F1C-9E0B-4ED5-B04B-6C043D14D1AA}.Release|Mixed Platforms.Build.0 = Release|Any CPU {3EA73F1C-9E0B-4ED5-B04B-6C043D14D1AA}.Release|x86.ActiveCfg = Release|Any CPU - {F3022BB7-0E40-4C80-A495-37FEAF3671AB}.Debug|Any CPU.ActiveCfg = Debug|x86 + {F3022BB7-0E40-4C80-A495-37FEAF3671AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F3022BB7-0E40-4C80-A495-37FEAF3671AB}.Debug|Any CPU.Build.0 = Debug|Any CPU {F3022BB7-0E40-4C80-A495-37FEAF3671AB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {F3022BB7-0E40-4C80-A495-37FEAF3671AB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {F3022BB7-0E40-4C80-A495-37FEAF3671AB}.Debug|x86.ActiveCfg = Debug|x86 @@ -69,7 +70,6 @@ Global {F3022BB7-0E40-4C80-A495-37FEAF3671AB}.Release|x86.ActiveCfg = Release|x86 {F3022BB7-0E40-4C80-A495-37FEAF3671AB}.Release|x86.Build.0 = Release|x86 {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Debug|Any CPU.Build.0 = Debug|Any CPU {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Debug|x86.ActiveCfg = Debug|Any CPU {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/Examples/Program.cs b/Examples/Program.cs index 17ca63c7..792ed7ae 100644 --- a/Examples/Program.cs +++ b/Examples/Program.cs @@ -24,6 +24,7 @@ static void Main(string[] args) HelloWorldKeepWithNext(); HelloWorldAdvancedFormatting(); HelloWorldProtectedDocument(); + HelloWorldAddPictureToWord(); RightToLeft(); Indentation(); HeadersAndFooters(); @@ -1825,7 +1826,58 @@ static void TableWithSpecifiedWidths() } + /// + /// Create a document with two pictures. One picture is inserted normal way, the other one with rotation + /// +static void HelloWorldAddPictureToWord() { + Console.WriteLine("\tHelloWorldAddPictureToWord()"); + // Create a document. + using (DocX document = DocX.Create(@"docs\HelloWorldAddPictureToWord.docx")) + { + // Add an image into the document. + RelativeDirectory rd = new RelativeDirectory(); // prepares the files for testing + rd.Up(2); + Image image = document.AddImage(rd.Path + @"\images\logo_template.png"); + + // Create a picture (A custom view of an Image). + Picture picture = image.CreatePicture(); + picture.Rotation = 10; + picture.SetPictureShape(BasicShapes.cube); + + // Insert a new Paragraph into the document. + Paragraph title = document.InsertParagraph().Append("This is a test for a picture").FontSize(20).Font(new FontFamily("Comic Sans MS")); + title.Alignment = Alignment.center; + + // Insert a new Paragraph into the document. + Paragraph p1 = document.InsertParagraph(); + + // Append content to the Paragraph + p1.AppendLine("Just below there should be a picture ").Append("picture").Bold().Append(" inserted in a non-conventional way."); + p1.AppendLine(); + p1.AppendLine("Check out this picture ").AppendPicture(picture).Append(" its funky don't you think?"); + p1.AppendLine(); + + // Insert a new Paragraph into the document. + Paragraph p2 = document.InsertParagraph(); + // Append content to the Paragraph. + + p2.AppendLine("Is it correct?"); + p2.AppendLine(); + + // Lets add another picture (without the fancy stuff) + Picture pictureNormal = image.CreatePicture(); + + Paragraph p3 = document.InsertParagraph(); + p3.AppendLine("Lets add another picture (without the fancy rotation stuff)"); + p3.AppendLine(); + p3.AppendPicture(pictureNormal); + + // Save this document. + document.Save(); + Console.WriteLine("\tCreated: docs\\HelloWorldAddPictureToWord.docx\n"); + } +} }