VerticalText.vb
''
'' This code is part of Document Solutions for Word demos.
'' Copyright (c) MESCIUS inc. All rights reserved.
''
Imports System.IO
Imports System.Drawing
Imports System.Collections.Generic
Imports GrapeCity.Documents.Word
Imports GrapeCity.Documents.Drawing
Imports GrapeCity.Documents.Pdf
Imports GrapeCity.Documents.Text

'' This sample draws Far Eastern text using a top-to-bottom, right-to-left page layout.
'' Other than the page layout, the code in this sample is similar to MultiLang sample.
Public Class VerticalText
    Public Function CreateDocx() As GcWordDocument
        Dim doc = New GcWordDocument()

        doc.Body.Sections.First.PageSetup.TextFlowDirection = TextFlowDirection.TopToBottomRightToLeft

        '' Add styles:
        Dim sCaption = doc.Styles.Add("My Caption", StyleType.Paragraph)
        sCaption.Font.Name = "Arial"
        sCaption.Font.Bold = True
        sCaption.Font.Size = 14
        sCaption.Font.Color.RGB = Color.AliceBlue
        sCaption.ParagraphFormat.KeepWithNext = True
        sCaption.ParagraphFormat.Shading.BackgroundPatternColor.RGB = Color.SteelBlue

        Dim sText = doc.Styles.Add("My Text", StyleType.Paragraph)
        sText.Font.Name = "MS PGothic"
        sText.Font.Size = 12
        sText.ParagraphFormat.KeepTogether = True
        sText.ParagraphFormat.Spacing.SpaceBeforeAuto = False
        '' In DsWord, all sizes, distances etc are in points (1/72"):
        sText.ParagraphFormat.Spacing.SpaceBefore = 18

        '' Draw texts in a loop:
        For i = 0 To s_texts.GetLength(0) - 1
            Dim Lang = s_texts(i, 0)
            Dim text = s_texts(i, 1)
            Dim rtl = Not String.IsNullOrEmpty(s_texts(i, 3))
            doc.Body.Sections.Last.GetRange().Paragraphs.Add(lang, sCaption)
            doc.Body.Sections.Last.GetRange().Paragraphs.Add(text, sText)
        Next

        '' Done:
        Return doc
    End Function


    '' 0 - Language tag
    '' 1 - Test string
    '' 2 - Font to use
    '' 3 - If not null/empty - the language is RTL
    Dim s_texts As String(,) =
        {
            {
                "Chinese",
                "漢語,又称中文、汉文、國文、國语、华文、华语,英文統一用「Chinese」,常用作简称现代标准汉语,古代的汉语称为文言文。属于汉藏语系分析语,有声调。汉语的文字系统汉字是一种意音文字,表意的同時也具一定的表音功能。漢語包含書面語以及口語兩部分。一般意義上,““漢語””這個詞,多指現代標準漢語,以北京语音为标准音、以北方话为基础方言、以典范的现代白话文著作为语法规范。[2]在中國大陆漢語語言文字課本中稱為語文。需要注意的是,中国大陆之““普通话””、台灣之““國語””、新马地区之““华语””,在某些漢字的取音上是有一定程度的差异的,而且口語讀音也出現不少分野,亦有一些汉字的读音在三者中根本不同。而大部分較中立的學者認為,漢語是眾多漢方言的統稱,是一個稱謂,可以指代任何其中一種方言(如粵語、吳語、客家話……),而非單一是語言。",
                "malgun",
                Nothing
            },
            {
                "Japanese",
                "日本語(にほんご、にっぽんご)は、主として、日本列島で使用されてきた言語である。日本手話を母語とする者などを除いて、ほぼ全ての日本在住者は日本語を第一言語とする。日本国は法令上、公用語を明記していないが、事実上の公用語となっており、学校教育の「国語」で教えられる。使用者は、日本国内を主として約1億3千万人。日本語の文法体系や音韻体系を反映する手話として日本語対応手話がある。",
                "malgun",
                Nothing
            },
            {
                "Korean",
                "한국어(韓國語)는 한반도 등지에서 주로 사용하는 언어로, 대한민국(남한)에서는 한국어, 한국말, 국어(國語)라고 부른다. 조선민주주의인민공화국(북한), 중국(조선족위주)을 비롯한 등지에서는 조선말, 조선어(朝鮮語)로, 카자흐스탄을 비롯 중앙아시아의 고려인들 사이에서는 고려말(高麗말)로 불린다.",
                "malgun",
                Nothing
            }
        }
End Class