From 342d009fcefbc7a30966bd2ab9207af237781a4d Mon Sep 17 00:00:00 2001 From: Venkateshmuruganandam Date: Fri, 6 Oct 2023 18:21:24 +0530 Subject: [PATCH 1/6] Update --- File-Formats/DocIO/Working-with-Paragraph.md | 78 ++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/File-Formats/DocIO/Working-with-Paragraph.md b/File-Formats/DocIO/Working-with-Paragraph.md index dd974f9e5..511bbc3f5 100644 --- a/File-Formats/DocIO/Working-with-Paragraph.md +++ b/File-Formats/DocIO/Working-with-Paragraph.md @@ -1765,6 +1765,84 @@ By executing the above code example, it generates output Word document as follow ![Output of Word document with Image caption](WorkingWithImages_images/ImageCaption.png) +### Add SVG image + +You can append SVG image specified by the byte array to the end of a paragraph using [AppendPicture](https://help.syncfusion.com/cr/file-formats/Syncfusion.DocIO.DLS.IWParagraph.html#Syncfusion_DocIO_DLS_IWParagraph_AppendPicture_System_Byte___System_Byte___) API. + +The following code example shows how to add SVG image in Word document. + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" %} + +///Creates a new Word document. +using (WordDocument document = new WordDocument()) +{ + //Add new section to the document + IWSection section = document.AddSection(); + //Add new paragraph to the section + IWParagraph firstParagraph = section.AddParagraph(); + //Get the image as byte array. + byte[] imageBytes = File.ReadAllBytes(Image.png); + //Get the SVG image as byte array. + byte[] svgData = File.ReadAllBytes(Image.svg"); + //Add SVG image to the paragraph + IWPicture picture = firstParagraph.AppendPicture(svgData, imageBytes); + //Set height and width for the image + picture.Height = 100; + picture.Width = 100; + //Saves the Word document to MemoryStream + MemoryStream stream = new MemoryStream(); + document.Save(stream, FormatType.Docx); +} + +{% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using (WordDocument document = new WordDocument()) +{ + //Add new section to the document. + IWSection section = document.AddSection(); + //Add new paragraph to the section. + IWParagraph firstParagraph = section.AddParagraph(); + //Get the image as byte array. + byte[] imageBytes = File.ReadAllBytes(Image.png); + //Get the SVG image as byte array. + byte[] svgData = File.ReadAllBytes(Image.svg"); + //Add SVG image to the paragraph. + IWPicture picture = firstParagraph.AppendPicture(svgData, imageBytes); + //Set height and width for the image. + picture.Height = 100; + picture.Width = 100; + //Saves the Word document. + document.Save("Sample.docx", FormatType.Docx); +} + +{% endhighlight %} +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} + +Using document As New WordDocument() + ' Add new section to the document. + Dim section As IWSection = document.AddSection() + ' Add new paragraph to the section. + Dim firstParagraph As IWParagraph = section.AddParagraph() + ' Get the PNG image as a byte array. + Dim imageBytes As Byte() = File.ReadAllBytes("Image.png") + ' Get the SVG image as a byte array. + Dim svgData As Byte() = File.ReadAllBytes("Image.svg") + ' Add SVG image to the paragraph. + Dim picture As IWPicture = firstParagraph.AppendPicture(svgData, ImageType.Metafile, imageBytes) + ' Set height and width for the image. + picture.Height = 100 + picture.Width = 100 + ' Save the Word document. + document.Save("Sample.docx", FormatType.Docx) +End Using + +{% endhighlight %} +{% endtabs %} + +You can download a complete working sample from GitHub. + ## Working with lists Lists can organize and format the contents of a document in hierarchical way. There are nine levels in the list, starting from level 0 to level 8. DocIO supports both built-in list styles and custom list styles. The following are the types of list supported in DocIO: From 4e61f0ac220c849842605ce275d238805d1d92de Mon Sep 17 00:00:00 2001 From: Venkateshmuruganandam Date: Fri, 6 Oct 2023 18:27:43 +0530 Subject: [PATCH 2/6] Modified --- File-Formats/DocIO/Working-with-Paragraph.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/File-Formats/DocIO/Working-with-Paragraph.md b/File-Formats/DocIO/Working-with-Paragraph.md index 511bbc3f5..6bd0bc614 100644 --- a/File-Formats/DocIO/Working-with-Paragraph.md +++ b/File-Formats/DocIO/Working-with-Paragraph.md @@ -1774,23 +1774,23 @@ The following code example shows how to add SVG image in Word document. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} -///Creates a new Word document. +///Create a new Word document. using (WordDocument document = new WordDocument()) { - //Add new section to the document + //Add new section to the document. IWSection section = document.AddSection(); - //Add new paragraph to the section + //Add new paragraph to the section. IWParagraph firstParagraph = section.AddParagraph(); //Get the image as byte array. byte[] imageBytes = File.ReadAllBytes(Image.png); //Get the SVG image as byte array. byte[] svgData = File.ReadAllBytes(Image.svg"); - //Add SVG image to the paragraph + //Add SVG image to the paragraph. IWPicture picture = firstParagraph.AppendPicture(svgData, imageBytes); - //Set height and width for the image + //Set height and width for the image. picture.Height = 100; picture.Width = 100; - //Saves the Word document to MemoryStream + //Save the Word document to MemoryStream. MemoryStream stream = new MemoryStream(); document.Save(stream, FormatType.Docx); } @@ -1813,7 +1813,7 @@ using (WordDocument document = new WordDocument()) //Set height and width for the image. picture.Height = 100; picture.Width = 100; - //Saves the Word document. + //Save the Word document. document.Save("Sample.docx", FormatType.Docx); } From ac34376b4fe6b0c8d4f4131a41c740f663e6b341 Mon Sep 17 00:00:00 2001 From: Venkateshmuruganandam Date: Mon, 9 Oct 2023 11:18:10 +0530 Subject: [PATCH 3/6] Modified --- File-Formats/DocIO/Working-with-Paragraph.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/File-Formats/DocIO/Working-with-Paragraph.md b/File-Formats/DocIO/Working-with-Paragraph.md index 6bd0bc614..a158ae38e 100644 --- a/File-Formats/DocIO/Working-with-Paragraph.md +++ b/File-Formats/DocIO/Working-with-Paragraph.md @@ -1784,7 +1784,7 @@ using (WordDocument document = new WordDocument()) //Get the image as byte array. byte[] imageBytes = File.ReadAllBytes(Image.png); //Get the SVG image as byte array. - byte[] svgData = File.ReadAllBytes(Image.svg"); + byte[] svgData = File.ReadAllBytes(Buyers.svg"); //Add SVG image to the paragraph. IWPicture picture = firstParagraph.AppendPicture(svgData, imageBytes); //Set height and width for the image. @@ -1807,7 +1807,7 @@ using (WordDocument document = new WordDocument()) //Get the image as byte array. byte[] imageBytes = File.ReadAllBytes(Image.png); //Get the SVG image as byte array. - byte[] svgData = File.ReadAllBytes(Image.svg"); + byte[] svgData = File.ReadAllBytes(Buyers.svg"); //Add SVG image to the paragraph. IWPicture picture = firstParagraph.AppendPicture(svgData, imageBytes); //Set height and width for the image. @@ -1828,7 +1828,7 @@ Using document As New WordDocument() ' Get the PNG image as a byte array. Dim imageBytes As Byte() = File.ReadAllBytes("Image.png") ' Get the SVG image as a byte array. - Dim svgData As Byte() = File.ReadAllBytes("Image.svg") + Dim svgData As Byte() = File.ReadAllBytes("Buyers.svg") ' Add SVG image to the paragraph. Dim picture As IWPicture = firstParagraph.AppendPicture(svgData, ImageType.Metafile, imageBytes) ' Set height and width for the image. From a988fec74516652d8f6bcbb417d4a8461cc28324 Mon Sep 17 00:00:00 2001 From: Venkateshmuruganandam Date: Tue, 10 Oct 2023 11:39:24 +0530 Subject: [PATCH 4/6] Updated. --- File-Formats/DocIO/Working-with-Paragraph.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/File-Formats/DocIO/Working-with-Paragraph.md b/File-Formats/DocIO/Working-with-Paragraph.md index a158ae38e..5cac97b28 100644 --- a/File-Formats/DocIO/Working-with-Paragraph.md +++ b/File-Formats/DocIO/Working-with-Paragraph.md @@ -1782,7 +1782,7 @@ using (WordDocument document = new WordDocument()) //Add new paragraph to the section. IWParagraph firstParagraph = section.AddParagraph(); //Get the image as byte array. - byte[] imageBytes = File.ReadAllBytes(Image.png); + byte[] imageBytes = File.ReadAllBytes(Buyers.png); //Get the SVG image as byte array. byte[] svgData = File.ReadAllBytes(Buyers.svg"); //Add SVG image to the paragraph. @@ -1805,7 +1805,7 @@ using (WordDocument document = new WordDocument()) //Add new paragraph to the section. IWParagraph firstParagraph = section.AddParagraph(); //Get the image as byte array. - byte[] imageBytes = File.ReadAllBytes(Image.png); + byte[] imageBytes = File.ReadAllBytes(Buyers.png); //Get the SVG image as byte array. byte[] svgData = File.ReadAllBytes(Buyers.svg"); //Add SVG image to the paragraph. @@ -1826,7 +1826,7 @@ Using document As New WordDocument() ' Add new paragraph to the section. Dim firstParagraph As IWParagraph = section.AddParagraph() ' Get the PNG image as a byte array. - Dim imageBytes As Byte() = File.ReadAllBytes("Image.png") + Dim imageBytes As Byte() = File.ReadAllBytes("Buyers.png") ' Get the SVG image as a byte array. Dim svgData As Byte() = File.ReadAllBytes("Buyers.svg") ' Add SVG image to the paragraph. From e0b05836060623915f744627155c4766be1e55cc Mon Sep 17 00:00:00 2001 From: Venkateshmuruganandam Date: Wed, 11 Oct 2023 11:26:16 +0530 Subject: [PATCH 5/6] Content modified --- File-Formats/DocIO/Working-with-Paragraph.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/File-Formats/DocIO/Working-with-Paragraph.md b/File-Formats/DocIO/Working-with-Paragraph.md index 5cac97b28..544219d78 100644 --- a/File-Formats/DocIO/Working-with-Paragraph.md +++ b/File-Formats/DocIO/Working-with-Paragraph.md @@ -1767,7 +1767,9 @@ By executing the above code example, it generates output Word document as follow ### Add SVG image -You can append SVG image specified by the byte array to the end of a paragraph using [AppendPicture](https://help.syncfusion.com/cr/file-formats/Syncfusion.DocIO.DLS.IWParagraph.html#Syncfusion_DocIO_DLS_IWParagraph_AppendPicture_System_Byte___System_Byte___) API. +To add an SVG image to a paragraph in a Word document using Syncfusion DocIO, you can use the [AppendPicture](https://help.syncfusion.com/cr/file-formats/Syncfusion.DocIO.DLS.IWParagraph.html#Syncfusion_DocIO_DLS_IWParagraph_AppendPicture_System_Byte___System_Byte___) API. + +N> To preserve the SVG image in the Word document, you need to pass both the SVG image data and the equivalent bitmap image bytes to DocIO. The following code example shows how to add SVG image in Word document. @@ -1841,7 +1843,7 @@ End Using {% endhighlight %} {% endtabs %} -You can download a complete working sample from GitHub. +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/DocIO-Examples/tree/main/Paragraphs/Add-svg-image/.NET). ## Working with lists From a282fd163b4a9841e56c278468acc668d5bf0e31 Mon Sep 17 00:00:00 2001 From: Venkateshmuruganandam Date: Thu, 12 Oct 2023 16:41:39 +0530 Subject: [PATCH 6/6] Modified --- File-Formats/DocIO/Working-with-Paragraph.md | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/File-Formats/DocIO/Working-with-Paragraph.md b/File-Formats/DocIO/Working-with-Paragraph.md index 544219d78..be2b0026d 100644 --- a/File-Formats/DocIO/Working-with-Paragraph.md +++ b/File-Formats/DocIO/Working-with-Paragraph.md @@ -1769,9 +1769,9 @@ By executing the above code example, it generates output Word document as follow To add an SVG image to a paragraph in a Word document using Syncfusion DocIO, you can use the [AppendPicture](https://help.syncfusion.com/cr/file-formats/Syncfusion.DocIO.DLS.IWParagraph.html#Syncfusion_DocIO_DLS_IWParagraph_AppendPicture_System_Byte___System_Byte___) API. -N> To preserve the SVG image in the Word document, you need to pass both the SVG image data and the equivalent bitmap image bytes to DocIO. +N> To preserve the SVG image in the Word document, pass both the SVG image data and the equivalent bitmap image bytes to DocIO. -The following code example shows how to add SVG image in Word document. +The following code example shows how to add an SVG image in a Word document. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} @@ -1779,13 +1779,13 @@ The following code example shows how to add SVG image in Word document. ///Create a new Word document. using (WordDocument document = new WordDocument()) { - //Add new section to the document. + //Add a new section to the document. IWSection section = document.AddSection(); - //Add new paragraph to the section. + //Add a new paragraph to the section. IWParagraph firstParagraph = section.AddParagraph(); - //Get the image as byte array. + //Get the image as a byte array. byte[] imageBytes = File.ReadAllBytes(Buyers.png); - //Get the SVG image as byte array. + //Get the SVG image as a byte array. byte[] svgData = File.ReadAllBytes(Buyers.svg"); //Add SVG image to the paragraph. IWPicture picture = firstParagraph.AppendPicture(svgData, imageBytes); @@ -1802,13 +1802,13 @@ using (WordDocument document = new WordDocument()) using (WordDocument document = new WordDocument()) { - //Add new section to the document. + //Add a new section to the document. IWSection section = document.AddSection(); - //Add new paragraph to the section. + //Add a new paragraph to the section. IWParagraph firstParagraph = section.AddParagraph(); - //Get the image as byte array. + //Get the image as a byte array. byte[] imageBytes = File.ReadAllBytes(Buyers.png); - //Get the SVG image as byte array. + //Get the SVG image as a byte array. byte[] svgData = File.ReadAllBytes(Buyers.svg"); //Add SVG image to the paragraph. IWPicture picture = firstParagraph.AppendPicture(svgData, imageBytes); @@ -1823,9 +1823,9 @@ using (WordDocument document = new WordDocument()) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Using document As New WordDocument() - ' Add new section to the document. + ' Add a new section to the document. Dim section As IWSection = document.AddSection() - ' Add new paragraph to the section. + ' Add a new paragraph to the section. Dim firstParagraph As IWParagraph = section.AddParagraph() ' Get the PNG image as a byte array. Dim imageBytes As Byte() = File.ReadAllBytes("Buyers.png")