Md2Word.vb
C# VB
'''' This code is part of Document Solutions for Word demos.'' Copyright (c) MESCIUS inc. All rights reserved.''Imports System.IOImports System.Collections.GenericImports System.LinqImports GrapeCity.Documents.Word
'' This example shows how to convert markdown (.md) documents'' to MS Word DOCX and PDF formats.'''' The conversion is done by the WordRenderer class'' that uses the Markdig package written by Alexandre Mutel'' to parse markdown, and the DsWord OM to create MS Word documents from it.'''' The WordRenderer VB source code is included in this sample, to view it'' download the sample zip. The renderer sources are located'' in the MarkdownToWord subdirectory of the sample zip.Public Class Md2Word Function CreateDocx(sampleParams As String()) As GcWordDocument Dim fn = Path.Combine(sampleParams(3).Split("/"c)) Dim markdown = File.ReadAllText(fn) Return WordRenderer.ToWord(markdown) End Function
Function CreateDocx(Optional parsIdx As Integer = 0) As GcWordDocument Return CreateDocx(GetSampleParamsList()(parsIdx)) End Function
Private Shared ReadOnly s_paramsList As New List(Of String())() From { New String() {"@md/DsPdfViewer README.md", "Convert the README.md file shipped with DsPdfViewer", Nothing, "Resources/Markdown/DsPdfViewer-README.md"}, New String() {"@md/DsPdfViewer CHANGELOG.md", "Convert the CHANGELOG.md file shipped with DsPdfViewer", Nothing, "Resources/Markdown/DsPdfViewer-CHANGELOG.md"}, New String() {"@md/spec.md", "Convert the Markdown specification spec.md file", Nothing, "Resources/Markdown/spec.md"} }
Public Shared Function GetSampleParamsList() As List(Of String()) Return s_paramsList End FunctionEnd Class