diff --git a/Document-Processing-toc.html b/Document-Processing-toc.html index efde45491..ea4d04c96 100644 --- a/Document-Processing-toc.html +++ b/Document-Processing-toc.html @@ -7862,11 +7862,29 @@ Markdown Library diff --git a/Document-Processing/Markdown/Markdown-Library/NET/Assemblies-Required.md b/Document-Processing/Markdown/Markdown-Library/NET/Assemblies-Required.md new file mode 100644 index 000000000..f3d57e93b --- /dev/null +++ b/Document-Processing/Markdown/Markdown-Library/NET/Assemblies-Required.md @@ -0,0 +1,43 @@ +--- +title: Assemblies required for .NET Markdown Library | Syncfusion +description: Learn the assemblies required to use the .NET Markdown library to create, read, and edit Markdown documents in your application. +platform: document-processing +control: Markdown +documentation: UG +--- + +# Assemblies Required for Markdown + +The following assemblies need to be referenced in your application to use the Syncfusion® Markdown library. + + + + + + + + + + + + + + + + + + +
Platform(s)

Assembly

+Windows Forms, WPF, ASP.NET MVC +

+Syncfusion.Markdown.Base +

+ ASP.NET Core, Blazor +

+Syncfusion.Markdown.Portable +

+ +T> 1. Switch to NuGet packages for a seamless experience: +T> * Get frequent bug fixes every week. +T> * Upgrade quickly with no manual effort. +T> Note: To avoid trial watermark when using NuGet packages, it is recommended to register license key in application. Please refer to this [link](https://help.syncfusion.com/common/essential-studio/licensing/overview) to know about registering Syncfusion® license key in your application to use our components. \ No newline at end of file diff --git a/Document-Processing/Markdown/Markdown-Library/NET/Document-Object-Model-representation.md b/Document-Processing/Markdown/Markdown-Library/NET/Document-Object-Model-representation.md new file mode 100644 index 000000000..6a807f658 --- /dev/null +++ b/Document-Processing/Markdown/Markdown-Library/NET/Document-Object-Model-representation.md @@ -0,0 +1,13 @@ +--- +title: Document Object Model of .NET Markdown library | Syncfusion +description: Learn here all about the Document Object Model (DOM) representation of Markdown documents and their elements in the Syncfusion .NET Markdown library. +platform: document-processing +control: Markdown +documentation: UG +--- + +# Document Object Model representation in Markdown + +When an existing Markdown document is opened or a new document is created, the Markdown library creates a **Document Object Model** (DOM) of the document in main memory. This object model can be used to manipulate the document as needed. + +![Document Object Model representation in Markdown](DocumentObjectModelrepresentation_images/DocumentObjectModelrepresentation_img1.png) \ No newline at end of file diff --git a/Document-Processing/Markdown/Markdown-Library/NET/DocumentObjectModelrepresentation_images/DocumentObjectModelrepresentation_img1.png b/Document-Processing/Markdown/Markdown-Library/NET/DocumentObjectModelrepresentation_images/DocumentObjectModelrepresentation_img1.png new file mode 100644 index 000000000..0bf0525d2 Binary files /dev/null and b/Document-Processing/Markdown/Markdown-Library/NET/DocumentObjectModelrepresentation_images/DocumentObjectModelrepresentation_img1.png differ diff --git a/Document-Processing/Markdown/Markdown-Library/NET/Getting-Started.md b/Document-Processing/Markdown/Markdown-Library/NET/Getting-Started.md index aaf74dc24..dcc13999f 100644 --- a/Document-Processing/Markdown/Markdown-Library/NET/Getting-Started.md +++ b/Document-Processing/Markdown/Markdown-Library/NET/Getting-Started.md @@ -7,8 +7,6 @@ documentation: UG --- # Getting started with Markdown library -## Creating a simple Markdown document from scratch - In this page, you can learn how to create a simple Markdown document programmatically using the Syncfusion Markdown API. @@ -31,7 +29,7 @@ Include the following namespace in your .cs or .vb code as shown below. {% tabs %} -{% highlight c# tabtitle="C# [Windows-specific]" %} +{% highlight c# tabtitle="C#" %} using Syncfusion.Office.Markdown; using System.Text; @@ -39,7 +37,7 @@ using System.IO; {% endhighlight %} -{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +{% highlight vb.net tabtitle="VB.NET" %} Imports System.IO Imports System.Text @@ -47,14 +45,6 @@ Imports Syncfusion.Office.Markdown {% endhighlight %} -{% highlight c# tabtitle="C# [Cross-platform]" %} - -using Syncfusion.Office.Markdown; -using System.Text; -using System.IO; - -{% endhighlight %} - {% endtabs %} ## Creating a new Markdown document from scratch with basic elements @@ -65,21 +55,16 @@ The following code example demonstrates how to create an instance of the Markdow {% tabs %} -{% highlight c# tabtitle="C# [Windows-specific]" %} +{% highlight c# tabtitle="C#" %} // Creates a new instance of MarkdownDocument. MarkdownDocument markdownDocument = new MarkdownDocument(); {% endhighlight %} -{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +{% highlight vb.net tabtitle="VB.NET" %} ' Creates a new instance of MarkdownDocument. Dim markdownDocument As New MarkdownDocument() {% endhighlight %} -{% highlight c# tabtitle="C# [Cross-platform]" %} -// Creates a new instance of MarkdownDocument. -MarkdownDocument markdownDocument = new MarkdownDocument(); -{% endhighlight %} - {% endtabs %} A Markdown document can contain various block-level elements such as headings, paragraphs, lists, tables, and code blocks. @@ -90,7 +75,7 @@ The following code example demonstrates how to add a heading to a Markdown docum {% tabs %} -{% highlight c# tabtitle="C# [Windows-specific]" %} +{% highlight c# tabtitle="C#" %} // Adds a heading to the Markdown document. MdParagraph mdHeadingParagraph = markdownDocument.AddParagraph(); @@ -101,7 +86,7 @@ mdHeadingTextRange.Text = "Adventure Works Cycles"; {% endhighlight %} -{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +{% highlight vb.net tabtitle="VB.NET" %} ' Adds a heading to the Markdown document. Dim mdHeadingParagraph As MdParagraph = markdownDocument.AddParagraph() @@ -112,17 +97,6 @@ mdHeadingTextRange.Text = "Adventure Works Cycles"; {% endhighlight %} -{% highlight c# tabtitle="C# [Cross-platform]" %} - -// Adds a heading to the Markdown document. -MdParagraph mdHeadingParagraph = markdownDocument.AddParagraph(); -// Applies the Heading 1 style to the paragraph. -mdHeadingParagraph.ApplyParagraphStyle("Heading 1"); -MdTextRange mdHeadingTextRange = mdHeadingParagraph.AddTextRange(); -mdHeadingTextRange.Text = "Adventure Works Cycles"; - -{% endhighlight %} - {% endtabs %} ### Adding a paragraph @@ -131,7 +105,7 @@ The following code example demonstrates how to add a paragraph to a Markdown doc {% tabs %} -{% highlight c# tabtitle="C# [Windows-specific]" %} +{% highlight c# tabtitle="C#" %} // Adds a paragraph to the Markdown document. MdParagraph mdParagraph = markdownDocument.AddParagraph(); @@ -140,7 +114,7 @@ The following code example demonstrates how to add a paragraph to a Markdown doc {% endhighlight %} -{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +{% highlight vb.net tabtitle="VB.NET" %} ' Adds a paragraph to the Markdown document. Dim mdParagraph As MdParagraph = markdownDocument.AddParagraph() @@ -149,15 +123,6 @@ The following code example demonstrates how to add a paragraph to a Markdown doc {% endhighlight %} -{% highlight c# tabtitle="C# [Cross-platform]" %} - -// Adds a paragraph to the Markdown document. - MdParagraph mdParagraph = markdownDocument.AddParagraph(); - MdTextRange mdTextRange = mdParagraph.AddTextRange(); - mdTextRange.Text = "Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is in Bothell, Washington with 290 employees, several regional sales teams are located throughout their market base."; - -{% endhighlight %} - {% endtabs %} ### Adding a list @@ -166,7 +131,7 @@ The Markdown library allows you to create both bulleted and numbered lists. The {% tabs %} -{% highlight c# tabtitle="C# [Windows-specific]" %} +{% highlight c# tabtitle="C#" %} // Adds the first list item. MdParagraph item1 = markdownDocument.AddParagraph(); @@ -192,7 +157,7 @@ item3.AddTextRange().Text = "Third item"; {% endhighlight %} -{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +{% highlight vb.net tabtitle="VB.NET" %} ' Adds the first list item. Dim item1 As MdParagraph = markdownDocument.AddParagraph() @@ -218,32 +183,6 @@ item3.AddTextRange().Text = "Third item"; {% endhighlight %} -{% highlight c# tabtitle="C# [Cross-platform]" %} - -// Adds the first list item. -MdParagraph item1 = markdownDocument.AddParagraph(); -item1.ListFormat = new MdListFormat(); -item1.ListFormat.IsNumbered = false; -item1.ListFormat.ListLevel = 0; -item1.ListFormat.ListValue = "- "; -item1.AddTextRange().Text = "First item"; -// Adds the second list item. -MdParagraph item2 = markdownDocument.AddParagraph(); -item2.ListFormat = new MdListFormat(); -item2.ListFormat.IsNumbered = false; -item2.ListFormat.ListLevel = 0; -item2.ListFormat.ListValue = "- "; -item2.AddTextRange().Text = "Second item"; -// Adds the third list item. -MdParagraph item3 = markdownDocument.AddParagraph(); -item3.ListFormat = new MdListFormat(); -item3.ListFormat.IsNumbered = false; -item3.ListFormat.ListLevel = 0; -item3.ListFormat.ListValue = "- "; -item3.AddTextRange().Text = "Third item"; - -{% endhighlight %} - {% endtabs %} ### Adding a table @@ -252,7 +191,7 @@ The following code example demonstrates how to add a table to a Markdown documen {% tabs %} -{% highlight c# tabtitle="C# [Windows-specific]" %} +{% highlight c# tabtitle="C#" %} // Adds a table to the Markdown document. MdTable table = markdownDocument.AddTable(); @@ -277,7 +216,7 @@ cell2.Items.Add(new MdTextRange { Text = "AdventureWorks Cycles, the fictitious {% endhighlight %} -{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +{% highlight vb.net tabtitle="VB.NET" %} ' Adds a table to the Markdown document. Dim table As MdTable = markdownDocument.AddTable() @@ -302,31 +241,6 @@ cell2.Items.Add(new MdTextRange { Text = "AdventureWorks Cycles, the fictitious {% endhighlight %} -{% highlight c# tabtitle="C# [Cross-platform]" %} - -// Adds a table to the Markdown document. -MdTable table = markdownDocument.AddTable(); -table.ColumnAlignments.Add(MdColumnAlignment.Left); -table.ColumnAlignments.Add(MdColumnAlignment.Left); -// Adds the header row. -MdTableRow headerRow = table.AddTableRow(); -MdTableCell header1 = headerRow.AddTableCell(); -header1.Items.Add(new MdTextRange { Text = "Profile picture" }); -MdTableCell header2 = headerRow.AddTableCell(); -header2.Items.Add(new MdTextRange { Text = "Description" }); - -// Adds a data row. -MdTableRow dataRow = table.AddTableRow(); -MdTableCell cell1 = dataRow.AddTableCell(); -MdPicture picture = new MdPicture(); -picture.Url = "Data\\photo.jpg"; -picture.AltText = "Profile picture"; -cell1.Items.Add(picture); -MdTableCell cell2 = dataRow.AddTableCell(); -cell2.Items.Add(new MdTextRange { Text = "AdventureWorks Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company." }); - -{% endhighlight %} - {% endtabs %} ### Saving the Markdown document @@ -335,7 +249,7 @@ After adding the required content, save the Markdown document to the file system {% tabs %} -{% highlight c# tabtitle="C# [Windows-specific]" %} +{% highlight c# tabtitle="C#" %} // Retrieves the Markdown document content. string mdContent = markdownDocument.GetMarkdownText(); @@ -344,7 +258,7 @@ File.WriteAllText("Output.md", mdContent, Encoding.UTF8); {% endhighlight %} -{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +{% highlight vb.net tabtitle="VB.NET" %} ' Retrieves the Markdown document content Dim mdContent As String = markdownDocument.GetMarkdownText() @@ -353,15 +267,6 @@ File.WriteAllText("Output.md", mdContent, Encoding.UTF8); {% endhighlight %} -{% highlight c# tabtitle="C# [Cross-platform]" %} - -// Retrieves the Markdown document content. -string mdContent = markdownDocument.GetMarkdownText(); -// Saves the Markdown document to the file system. -File.WriteAllText("Output.md", mdContent, Encoding.UTF8); - -{% endhighlight %} - {% endtabs %} You can download a complete working sample from GitHub. diff --git a/Document-Processing/Markdown/Markdown-Library/NET/Loading-and-Saving-document.md b/Document-Processing/Markdown/Markdown-Library/NET/Loading-and-Saving-document.md new file mode 100644 index 000000000..3bc5ea60b --- /dev/null +++ b/Document-Processing/Markdown/Markdown-Library/NET/Loading-and-Saving-document.md @@ -0,0 +1,196 @@ +--- +title: Loading and Saving Markdown document in C# | Syncfusion +description: Learn how to load and save a Markdown document in C# and VB.NET using Syncfusion® .NET Markdown library without external dependencies. +platform: document-processing +control: Markdown +documentation: UG +--- + + +# Loading and Saving a Markdown Document + +The Syncfusion® Markdown library allows you to load an existing Markdown document and save it to the file system programmatically. + +## Namespaces required + +The following namespaces of Essential® Markdown need to be included in your application to load and save the Markdown document. + +{% tabs %} + +{% highlight c# tabtitle="C#" %} + +using Syncfusion.Office.Markdown; +using System.Text; +using System.IO; + +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET" %} + +Imports System.IO +Imports System.Text +Imports Syncfusion.Office.Markdown + +{% endhighlight %} + +{% endtabs %} + +## Opening an existing Markdown document + +You can open an existing Markdown document by using either the **Open** method or the constructor of the **MarkdownDocument** class. + +### Opening using constructor + +The `MarkdownDocument` class allows you to open an existing Markdown document by passing the stream and import settings as constructor parameters. + +The following code example demonstrates how to open an existing Markdown document using the constructor. + + +{% tabs %} + +{% highlight c# tabtitle="C#" %} + +// Opens an existing Markdown document using constructor. +FileStream fileStream = new FileStream("Input.md", FileMode.Open, FileAccess.Read); +MdImportSettings mdImportSettings = new MdImportSettings(); +MarkdownDocument markdownDocument = new MarkdownDocument(fileStream, mdImportSettings); + +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET" %} + +' Opens an existing Markdown document using constructor. +Dim fileStream As New FileStream("Input.md", FileMode.Open, FileAccess.Read) +Dim mdImportSettings As New MdImportSettings() +Dim markdownDocument As New MarkdownDocument(fileStream, mdImportSettings) + +{% endhighlight %} + +{% endtabs %} + +### Opening using Open Method + +The `MarkdownDocument` class also provides the `Open` method to open an existing Markdown document from a stream. + +The following code example demonstrates how to open an existing Markdown document using the `Open` method. + +{% tabs %} + +{% highlight c# tabtitle="C#" %} + +// Creates an empty MarkdownDocument instance +MarkdownDocument markdownDocument = new MarkdownDocument(); +// Opens an existing Markdown document using the Open method. +FileStream fileStream = new FileStream("Input.md", FileMode.Open, FileAccess.Read); +MdImportSettings settings = new MdImportSettings(); +markdownDocument.Open(fileStream, settings); + +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET" %} + +' Creates a new instance of MarkdownDocument. +Dim markdownDocument As New MarkdownDocument() +' Opens an existing Markdown document using the Open method. +Dim fileStream As New FileStream("Input.md", FileMode.Open, FileAccess.Read) +Dim mdImportSettings As New MdImportSettings() +markdownDocument.Open(fileStream, mdImportSettings) + +{% endhighlight %} + +{% endtabs %} + +You can download a complete working sample from GitHub. + +## Saving a Markdown Document + +After modifying a Markdown document, you can save it to the file system using the `GetMarkdownText` method, which retrieves the Markdown content as a string, and then write the content to a file using the `File.WriteAllText` method. + +The following code example demonstrates how to save a Markdown document to the file system. + +{% tabs %} + +{% highlight c# tabtitle="C#" %} + +// Creates an empty MarkdownDocument instance +MarkdownDocument markdownDocument = new MarkdownDocument(); +// Opens an existing Markdown document using the Open method. +FileStream fileStream = new FileStream("Input.md", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); +MdImportSettings settings = new MdImportSettings(); +markdownDocument.Open(fileStream, settings); +// To-Do some manipulation +// To-Do some manipulation +// Retrieves the Markdown document content. +string mdContent = markdownDocument.GetMarkdownText(); +// Saves the Markdown document to the file system. +File.WriteAllText("Output.md", mdContent, Encoding.UTF8); + +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET" %} + +' Creates a new instance of MarkdownDocument. +Dim markdownDocument As New MarkdownDocument() +' Opens an existing Markdown document using the Open method. +Dim fileStream As New FileStream("Input.md", FileMode.Open, FileAccess.Read) +Dim mdImportSettings As New MdImportSettings() +markdownDocument.Open(fileStream, mdImportSettings) +'To-Do some manipulation +'To-Do some manipulation +' Retrieves the Markdown document content. +Dim mdContent As String = markdownDocument.GetMarkdownText() +' Saves the Markdown document to the file system. +File.WriteAllText("Output.md", mdContent, Encoding.UTF8) + +{% endhighlight %} + +{% endtabs %} + +## Closing a document + +Once the document manipulation and save operations are completed, you should close or dispose the instance of MarkdownDocument instance in order to release all the memory consumed by the Markdown library's DOM. The following code example illustrates how to close a `MarkdownDocument` instance. + +{% tabs %} + +{% highlight c# tabtitle="C#" %} + +// Opens, saves and closes a Markdown document. +FileStream fileStream = new FileStream("Input.md", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); +MdImportSettings settings = new MdImportSettings(); +MarkdownDocument markdownDocument = new MarkdownDocument(fileStream, settings); + +// To-Do some manipulation +// To-Do some manipulation + +// Retrieves the Markdown document content. +string markdownText = markdownDocument.GetMarkdownText(); +//Save the Markdown content to the file system +File.WriteAllText("Output.md", markdownText, Encoding.UTF8); + +//Dispose the document to release all memory +markdownDocument.Dispose(); + +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET" %} + +' Opens, saves and closes a Markdown document. +Dim fileStream As New FileStream("Input.md", FileMode.Open, FileAccess.Read) +Dim settings As New MdImportSettings() +Dim markdownDocument As New MarkdownDocument(fileStream, settings) + +'To-Do some manipulation +'To-Do some manipulation + +' Retrieves the Markdown document content. +Dim markdownText As String = markdownDocument.GetMarkdownText() +' Saves the Markdown document to the file system. +File.WriteAllText("Output.md", markdownText, Encoding.UTF8) + +' Disposes the document to release all memory. +markdownDocument.Dispose() + +{% endhighlight %} +{% endtabs %} + +You can download a complete working sample from GitHub. diff --git a/Document-Processing/Markdown/Markdown-Library/NET/NuGet-Packages-Required.md b/Document-Processing/Markdown/Markdown-Library/NET/NuGet-Packages-Required.md new file mode 100644 index 000000000..0491df4f2 --- /dev/null +++ b/Document-Processing/Markdown/Markdown-Library/NET/NuGet-Packages-Required.md @@ -0,0 +1,63 @@ +--- +title: NuGet Packages for .NET Markdown Library | Syncfusion +description: Learn the NuGet packages required to use the .NET Markdown library to create, read, and edit Markdown documents without external dependencies. +platform: document-processing +control: Markdown +documentation: UG +--- + +# NuGet Packages Required for Markdown Library + +## Installing Syncfusion® Markdown through NuGet Packages + +NuGet is the one of the easiest way to download and install Markdown library to create, read, and edit the Markdown documents. The following NuGet packages need to be installed in your application. + +
+ + + + + + + + + + + + +
+Platform(s) + +Package name + +Package manager console command +
+Windows Forms / Console (.NET Framework) / WPF / ASP.NET MVC5 / ASP.NET Core / Console (.NET Core) / Blazor / WinUI / MAUI + +Syncfusion.Markdown.nupkg + +Install-Package Syncfusion.Markdown +
+ +N> 1. Syncfusion® components are available in [nuget.org](https://www.nuget.org/) + +## NuGet Package Installation and Uninstallation + +To use Syncfusion® NuGet packages in your project, please refer the NuGet Package [Installation](https://help.syncfusion.com/extension/syncfusion-nuget-packages/nuget-packages) and [Uninstallation](https://help.syncfusion.com/extension/syncfusion-nuget-packages/nuget-uninstallation-process#) sections. + +Markdown NuGet packages can be installed and uninstalled using Package Manager Console. + +In Visual Studio, select `Tools > NuGet Package Manager > Package Manager Console` and execute the following commands. + +**NuGet Package:** Syncfusion.Markdown + +The package contains Markdown library that allows you to create, read and edit Markdown documents. + +~~~ +// Install package +Install-Package Syncfusion.Markdown +~~~ +~~~ +// Uninstall package +Uninstall-Package Syncfusion.Markdown -RemoveDependencies +~~~ \ No newline at end of file