VerticalText.cs
  1. //
  2. // This code is part of Document Solutions for Word demos.
  3. // Copyright (c) MESCIUS inc. All rights reserved.
  4. //
  5. using System;
  6. using System.IO;
  7. using System.Drawing;
  8. using System.Collections.Generic;
  9. using GrapeCity.Documents.Word;
  10. using GrapeCity.Documents.Drawing;
  11. using GrapeCity.Documents.Pdf;
  12. using GrapeCity.Documents.Text;
  13.  
  14. namespace DsWordWeb.Demos
  15. {
  16. // This sample draws Far Eastern text using a top-to-bottom, right-to-left page layout.
  17. // Other than the page layout, the code in this sample is similar to MultiLang sample.
  18. public class VerticalText
  19. {
  20. public GcWordDocument CreateDocx()
  21. {
  22. var doc = new GcWordDocument();
  23.  
  24. doc.Body.Sections.First.PageSetup.TextFlowDirection = TextFlowDirection.TopToBottomRightToLeft;
  25.  
  26. // Add styles:
  27. var sCaption = doc.Styles.Add("My Caption", StyleType.Paragraph);
  28. sCaption.Font.Name = "Arial";
  29. sCaption.Font.Bold = true;
  30. sCaption.Font.Size = 14;
  31. sCaption.Font.Color.RGB = Color.AliceBlue;
  32. sCaption.ParagraphFormat.KeepWithNext = true;
  33. sCaption.ParagraphFormat.Shading.BackgroundPatternColor.RGB = Color.SteelBlue;
  34.  
  35. var sText = doc.Styles.Add("My Text", StyleType.Paragraph);
  36. sText.Font.Name = "MS PGothic";
  37. sText.Font.Size = 12;
  38. sText.ParagraphFormat.KeepTogether = true;
  39. sText.ParagraphFormat.Spacing.SpaceBeforeAuto = false;
  40. // In DsWord, all sizes, distances etc are in points (1/72"):
  41. sText.ParagraphFormat.Spacing.SpaceBefore = 18;
  42.  
  43. // Draw texts in a loop:
  44. for (int i = 0; i < s_texts.GetLength(0); ++i)
  45. {
  46. string lang = s_texts[i, 0];
  47. string text = s_texts[i, 1];
  48. bool rtl = !string.IsNullOrEmpty(s_texts[i, 3]);
  49. doc.Body.Sections.Last.GetRange().Paragraphs.Add(lang, sCaption);
  50. doc.Body.Sections.Last.GetRange().Paragraphs.Add(text, sText);
  51. }
  52.  
  53. // Done:
  54. return doc;
  55. }
  56.  
  57. // 0 - Language tag
  58. // 1 - Test string
  59. // 2 - Font to use
  60. // 3 - If not null/empty - the language is RTL
  61. string[,] s_texts = new string[,]
  62. {
  63. {
  64. "Chinese",
  65. "漢語,又称中文、汉文、國文、國语、华文、华语,英文統一用「Chinese」,常用作简称现代标准汉语,古代的汉语称为文言文。属于汉藏语系分析语,有声调。汉语的文字系统汉字是一种意音文字,表意的同時也具一定的表音功能。漢語包含書面語以及口語兩部分。一般意義上,“漢語”這個詞,多指現代標準漢語,以北京语音为标准音、以北方话为基础方言、以典范的现代白话文著作为语法规范。[2]在中國大陆漢語語言文字課本中稱為語文。需要注意的是,中国大陆之“普通话”、台灣之“國語”、新马地区之“华语”,在某些漢字的取音上是有一定程度的差异的,而且口語讀音也出現不少分野,亦有一些汉字的读音在三者中根本不同。而大部分較中立的學者認為,漢語是眾多漢方言的統稱,是一個稱謂,可以指代任何其中一種方言(如粵語、吳語、客家話……),而非單一是語言。",
  66. "malgun",
  67. null
  68. },
  69. {
  70. "Japanese",
  71. "日本語(にほんご、にっぽんご)は、主として、日本列島で使用されてきた言語である。日本手話を母語とする者などを除いて、ほぼ全ての日本在住者は日本語を第一言語とする。日本国は法令上、公用語を明記していないが、事実上の公用語となっており、学校教育の「国語」で教えられる。使用者は、日本国内を主として約1億3千万人。日本語の文法体系や音韻体系を反映する手話として日本語対応手話がある。",
  72. "malgun",
  73. null
  74. },
  75. {
  76. "Korean",
  77. "한국어(韓國語)는 한반도 등지에서 주로 사용하는 언어로, 대한민국(남한)에서는 한국어, 한국말, 국어(國語)라고 부른다. 조선민주주의인민공화국(북한), 중국(조선족위주)을 비롯한 등지에서는 조선말, 조선어(朝鮮語)로, 카자흐스탄을 비롯 중앙아시아의 고려인들 사이에서는 고려말(高麗말)로 불린다.",
  78. "malgun",
  79. null
  80. },
  81. };
  82. }
  83. }
  84.