public void ConvertToTextlines_Text()
        {
            Page page = new Page(new Document(), "PAGE", "200mm", "200mm", "rgb", "3mm", 1);

            Font      f  = new Font("FONT", @"C:\Windows\Fonts", "UTF-8", "false", "10pt");
            FontStyle fs = new FontStyle(f, "STYLE", "arial.ttf");

            f.AddStyle(fs);

            Content container = new Content(page);

            object[] paramList = new object[2];
            paramList[0] = container;
            paramList[1] = "TEXT";

            OpenTemplater.Models.Text.Text text = MockRepository.GeneratePartialMock <OpenTemplater.Models.Text.Text>(paramList);

            Paragraph p = new Paragraph(text, "10pt", "left");

            TextElement te = new TextElement(p, "Dit is een hele mooie tekst.", fs, new Unit(10), new Color("blue"));

            p.Add(te);
            p.Add(te);
            p.Add(te);

            text.Add(p);

            TextModule         tm = new TextModule();
            TextlineCollection textlineCollection = tm.ConvertToTextlines(new Unit("35mm"), text);

            // There should be 4 texlines.
            Assert.AreEqual(4, textlineCollection.Count);

            // Each textline should be shorter than 35 milimeters.
            foreach (Textline textline in textlineCollection)
            {
                Assert.AreEqual(true, textline.Width.Points <= new Unit("35mm").Points);
            }

            // The total height of the textlines should be 40mm.
            Assert.AreEqual(40, textlineCollection.Height.Points);
        }
Exemple #2
0
        public void SetTextlines()
        {
            var textModule = new TextModule();

            TextlineCollection      lines  = textModule.ConvertToTextlines(LayoutContainer.Layout.Width, this);
            TextlineMeasuringOutput output = textModule.SplitTextlines(lines,
                                                                       LayoutContainer.Layout.Height.Points);

            if (Textlines == null)
            {
                Textlines = output.FittingLines;

                LayoutContainer.TryResize(Textlines.Width, Textlines.Height);

                var overflowText = OverflowElement as Text;

                if (overflowText != null)
                {
                    overflowText.Textlines.AddRange(output.NotFittingLines);
                }
            }
        }