Ejemplo n.º 1
0
        public float[] DrawOn(Page page)
        {
            float xText = x;
            float yText = y + font.ascent;

            while (paragraphs.Count > 0)
            {
                // The paragraphs are reversed so we can efficiently remove the first one:
                TextLine textLine = paragraphs[paragraphs.Count - 1];
                paragraphs.RemoveAt(paragraphs.Count - 1);
                textLine.SetLocation(xText, yText);
                beginParagraphPoints.Add(new float[] { xText, yText });
                while (true)
                {
                    textLine = DrawLineOnPage(textLine, page);
                    if (textLine.GetText().Equals(""))
                    {
                        break;
                    }
                    yText = textLine.Advance(leading);
                    if (yText + font.descent >= (y + h))
                    {
                        // The paragraphs are reversed so we can efficiently add new first paragraph:
                        paragraphs.Add(textLine);

                        if (page != null && drawBorder)
                        {
                            Box box = new Box();
                            box.SetLocation(x, y);
                            box.SetSize(w, h);
                            box.DrawOn(page);
                        }

                        return(new float[] { x + w, y + h });
                    }
                }
                xText  = x;
                yText += paragraphLeading;
            }

            if (page != null && drawBorder)
            {
                Box box = new Box();
                box.SetLocation(x, y);
                box.SetSize(w, h);
                box.DrawOn(page);
            }

            return(new float[] { x + w, y + h });
        }