コード例 #1
0
        /// <summary>
        /// Modify the direction of text in a paragraph or document.
        /// </summary>
        public static void SetDirection()
        {
            Console.WriteLine("\tSetDirection()");

            // Create a document.
            using (DocX document = DocX.Create(MarginSample.MarginSampleOutputDirectory + @"SetDirection.docx"))
            {
                // Add a title.
                document.InsertParagraph("Modify direction of paragraphs").FontSize(15d).SpacingAfter(50d).Alignment = Alignment.center;

                // Add first paragraph.
                var p = document.InsertParagraph("This is the first paragraph.");
                p.SpacingAfter(30);

                // Add second paragraph.
                var p2 = document.InsertParagraph("This is the second paragraph.");
                p2.SpacingAfter(30);
                // Make this Paragraph flow right to left. Default is left to right.
                p2.Direction = Direction.RightToLeft;

                // Add third paragraph.
                var p3 = document.InsertParagraph("This is the third paragraph.");
                p3.SpacingAfter(30);

                // Add fourth paragraph.
                var p4 = document.InsertParagraph("This is the fourth paragraph.");
                p4.SpacingAfter(30);

                // To modify the direction of each paragraph in a document, just set the direction on the document.
                document.SetDirection(Direction.RightToLeft);

                document.Save();
                Console.WriteLine("\tCreated: SetDirection.docx\n");
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: minhkiet/DocX-1
        /// <summary>
        /// Create a document that with RightToLeft text flow.
        /// </summary>
        private static void RightToLeft()
        {
            Console.WriteLine("\tRightToLeft()");

            // Create a new document.
            using (DocX document = DocX.Create(@"docs\RightToLeft.docx"))
            {
                // Create a new Paragraph with the text "Hello World".
                Paragraph p = document.InsertParagraph("Hello World.");

                // Make this Paragraph flow right to left. Default is left to right.
                p.Direction = Direction.RightToLeft;

                // You don't need to manually set the text direction foreach Paragraph, you can just call this function.
                document.SetDirection(Direction.RightToLeft);

                // Save all changes made to this document.
                document.Save();
                Console.WriteLine("\tCreated: docs\\RightToLeft.docx\n");
            }
        }