Ejemplo n.º 1
0
 public void AddChineseParagraph(Font font, String chinese)
 {
     Paragraph p = null;
     StringBuilder buf = new StringBuilder();
     for (int i = 0; i < chinese.Length; i++) {
     char ch = chinese[i];
     if (font.StringWidth(buf.ToString() + ch) > w) {
         p = new Paragraph();
         p.Add(new TextLine(font, buf.ToString()));
         AddParagraph(p);
         buf.Length = 0;
     }
     buf.Append(ch);
     }
     p = new Paragraph();
     p.Add(new TextLine(font, buf.ToString()));
     AddParagraph(p);
 }
Ejemplo n.º 2
0
 /**
  *  Adds a new paragraph to this text column.
  *
  *  @param paragraph the new paragraph object.
  */
 public void AddParagraph(Paragraph paragraph)
 {
     this.paragraphs.Add(paragraph);
 }
Ejemplo n.º 3
0
        private Point DrawParagraphOn(
            Page page, Paragraph paragraph, bool draw)
        {
            List<TextLine> list = new List<TextLine>();
            float run_length = 0f;
            for (int i = 0; i < paragraph.list.Count; i++) {
            TextLine line = paragraph.list[i];
            if (i == 0) {
                line_height = line.font.body_height + space_between_lines;
                if (rotate == 0) {
                    y1 += line.font.ascent;
                }
                else if (rotate == 90) {
                    x1 += line.font.ascent;
                }
                else if (rotate == 270) {
                    x1 -= line.font.ascent;
                }
            }

            String[] tokens = line.str.Split(new Char[] {' ', '\r', '\n', '\t'});
            TextLine text = null;
            for (int j = 0; j < tokens.Length; j++) {
                String str = tokens[j];
                text = new TextLine(line.font, str);
                text.SetColor(line.GetColor());
                text.SetUnderline(line.GetUnderline());
                text.SetStrikeout(line.GetStrikeout());
                text.SetURIAction(line.GetURIAction());
                text.SetGoToAction(line.GetGoToAction());
                text.SetFallbackFont(line.GetFallbackFont());
                run_length += line.font.StringWidth(line.GetFallbackFont(), str);
                if (run_length >= w) {
                    DrawLineOfText(page, list, draw);
                    MoveToNextLine();
                    list.Clear();
                    list.Add(text);
                    run_length = line.font.StringWidth(line.GetFallbackFont(), str + " ");
                }
                else {
                    list.Add(text);
                    run_length += line.font.StringWidth(line.GetFallbackFont(), " ");
                }
            }
            }
            DrawNonJustifiedLine(page, list, draw);

            if (lineBetweenParagraphs) {
            return MoveToNextLine();
            }

            return MoveToNextParagraph(this.space_between_paragraphs);
        }