public static void TextMarkup13()
        {
            var page     = SampleEnvironment.Application.ActiveDocument.Pages.Add();
            var segoe_ui = page.Document.Fonts["Segoe UI"];

            // Create the Shapes that will hold the text
            var s1 = page.DrawRectangle(0, 0, 8.5, 11);
            var e1 = new VAM.Text.Element();

            e1.AddText("When, from behind that craggy steep\n");
            e1.AddText("till then the horizon’s bound\n");

            var f2 = new TextFmt {
                HAlign = VSM.AlignmentHorizontal.Left, CharStyle = VAM.Text.CharStyle.Italic
            };
            var f3 = new TextFmt {
                FontID = segoe_ui.ID, HAlign = VSM.AlignmentHorizontal.Center, CharStyle = VAM.Text.CharStyle.Bold
            };
            var f4 = new TextFmt {
                HAlign = VSM.AlignmentHorizontal.Right, CharStyle = VAM.Text.CharStyle.Italic
            };

            var e2 = e1.AddElementEx("a huge peak, black and huge\n", f2);
            var e3 = e1.AddElementEx("As if with voluntary power instinct\n", f3);
            var e4 = e1.AddElementEx("Upreared its head.\n", f4);

            e1.AddText("-William Wordsworth, the Prelude");
            e1.SetText(s1);
        }
Example #2
0
        public static VAM.Text.Element AddElementEx(
            this VAM.Text.Element p,
            string text,
            TextFmt textfmt)
        {
            var el = p.AddElement(text);

            if (textfmt != null && textfmt.FontID != null)
            {
                el.CharacterFormatting.Font = textfmt.FontID.Value;
            }

            if (textfmt != null && textfmt.FontSize.HasValue)
            {
                el.CharacterFormatting.Size = string.Format("{0}pt", textfmt.FontSize.Value);
            }

            if (textfmt != null && textfmt.Color.HasValue)
            {
                var c = new VAM.Color.ColorRgb(textfmt.Color.Value);
                el.CharacterFormatting.Color = c.ToFormula();
            }

            if (textfmt != null && textfmt.HAlign.HasValue)
            {
                el.ParagraphFormatting.HorizontalAlign = (int)textfmt.HAlign.Value;
            }

            if (textfmt != null && textfmt.CharStyle.HasValue)
            {
                el.CharacterFormatting.Style = (int)textfmt.CharStyle;
            }

            return(el);
        }
        public static void TextMarkup12()
        {
            var page = SampleEnvironment.Application.ActiveDocument.Pages.Add();

            // Create the Shapes that will hold the text
            var s1  = page.DrawRectangle(0, 0, 8.5, 11);
            var tnr = page.Document.Fonts["Times New Roman"];

            var e1        = new VAM.Text.Element();
            var color_red = new VAM.Color.ColorRgb(0xff0000);

            e1.CharacterFormatting.Color = color_red.ToFormula();
            e1.CharacterFormatting.Font  = tnr.ID;
            e1.CharacterFormatting.Font  = "20pt";
            e1.AddText("Hello ");

            var f2 = new TextFmt {
                CharStyle = VAM.Text.CharStyle.Italic
            };
            var e2 = e1.AddElementEx("World", f2);

            e1.SetText(s1);
        }