Пример #1
0
 private void StrikeoutText(Page page, Font font, string text, float x, float y)
 {
     page.SetPenWidth(font.underlineThickness);
     page.MoveTo((double)x, (double)y - (double)font.GetAscent() / 3.0);
     page.LineTo((double)(x + font.StringWidth(text)), (double)y - (double)font.GetAscent() / 3.0);
     page.StrokePath();
 }
Пример #2
0
 private void StrikeoutText(
     Page page, Font font, String text, float x, float y)
 {
     page.SetPenWidth(font.underlineThickness);
     page.MoveTo(x, y - font.GetAscent() / 3f);
     page.LineTo(x + font.StringWidth(text), y - font.GetAscent() / 3f);
     page.StrokePath();
 }
Пример #3
0
 private void StrikeoutText(
     Page page, Font font, String text, float x, float y)
 {
     page.AddBMC(StructElem.SPAN, Single.space, Single.space);
     page.SetPenWidth(font.underlineThickness);
     page.MoveTo(x, y - font.GetAscent() / 3f);
     page.LineTo(x + font.StringWidth(text), y - font.GetAscent() / 3f);
     page.StrokePath();
     page.AddEMC();
 }
Пример #4
0
        /**
         *  Draws this RadioButton on the specified Page.
         *
         *  @param page the Page where the RadioButton is to be drawn.
         */
        public float[] DrawOn(Page page)
        {
            page.AddBMC(StructElem.SPAN, language, altDescription, actualText);

            this.r1       = font.GetAscent() / 2;
            this.r2       = r1 / 2;
            this.penWidth = r1 / 10;

            float y_box = y - font.GetAscent();

            page.SetPenWidth(1f);
            page.SetPenColor(Color.black);
            page.SetLinePattern("[] 0");
            page.SetBrushColor(Color.black);
            page.DrawCircle(x + r1, y_box + r1, r1);

            if (this.selected)
            {
                page.DrawCircle(x + r1, y_box + r1, r2, Operation.FILL);
            }

            if (uri != null)
            {
                page.SetBrushColor(Color.blue);
            }
            page.DrawString(font, label, x + 3 * r1, y);
            page.SetPenWidth(0f);
            page.SetBrushColor(Color.black);

            page.AddEMC();

            if (uri != null)
            {
                // Please note: The font descent is a negative number.
                page.AddAnnotation(new Annotation(
                                       uri,
                                       null,
                                       x + 3 * r1,
                                       page.height - y,
                                       x + 3 * r1 + font.StringWidth(label),
                                       page.height - (y - font.GetAscent()),
                                       language,
                                       altDescription,
                                       actualText));
            }

            return(new float[] { x + 6 * r1 + font.StringWidth(label), y + font.GetBodyHeight() });
        }
Пример #5
0
 public float[] DrawOn(Page page, bool draw)
 {
     this.x_text = x;
     this.y_text = y + font.GetAscent();
     foreach (Paragraph paragraph in paragraphs)
     {
         int           numberOfTextLines = paragraph.list.Count;
         StringBuilder buf = new StringBuilder();
         for (int i = 0; i < numberOfTextLines; i++)
         {
             TextLine textLine = paragraph.list[i];
             buf.Append(textLine.GetText());
         }
         for (int i = 0; i < numberOfTextLines; i++)
         {
             TextLine textLine = paragraph.list[i];
             if (i == 0)
             {
                 beginParagraphPoints.Add(new float[] { x_text, y_text });
             }
             textLine.SetAltDescription((i == 0) ? buf.ToString() : Single.space);
             textLine.SetActualText((i == 0) ? buf.ToString() : Single.space);
             float[] point = DrawTextLine(page, x_text, y_text, textLine, draw);
             if (i == (numberOfTextLines - 1))
             {
                 endParagraphPoints.Add(new float[] { point[0], point[1] });
             }
             x_text = point[0] + spaceBetweenTextLines;
             y_text = point[1];
         }
         x_text  = x;
         y_text += paragraphLeading;
     }
     return(new float[] { x_text, y_text + font.GetDescent() });
 }
Пример #6
0
        /**
         *  Draws this RadioButton on the specified Page.
         *
         *  @param page the page to draw on.
         *  @return x and y coordinates of the bottom right corner of this component.
         *  @throws Exception
         */
        public float[] DrawOn(Page page)
        {
            page.AddBMC(StructElem.SPAN, language, altDescription, actualText);

            this.r1       = font.GetAscent() / 2;
            this.r2       = r1 / 2;
            this.penWidth = r1 / 10;

            float yBox = y;

            page.SetPenWidth(1f);
            page.SetPenColor(Color.black);
            page.SetLinePattern("[] 0");
            page.SetBrushColor(Color.black);
            page.DrawCircle(x + r1 + penWidth, yBox + r1 + penWidth, r1);

            if (this.selected)
            {
                page.DrawCircle(x + r1 + penWidth, yBox + r1 + penWidth, r2, Operation.FILL);
            }

            if (uri != null)
            {
                page.SetBrushColor(Color.blue);
            }
            page.DrawString(font, label, x + 3 * r1, y + font.ascent);
            page.SetPenWidth(0f);
            page.SetBrushColor(Color.black);

            page.AddEMC();

            if (uri != null)
            {
                page.AddAnnotation(new Annotation(
                                       uri,
                                       null,
                                       x + 3 * r1,
                                       y,
                                       x + 3 * r1 + font.StringWidth(label),
                                       y + font.bodyHeight,
                                       language,
                                       altDescription,
                                       actualText));
            }

            return(new float[] { x + 6 * r1 + font.StringWidth(label), y + font.bodyHeight });
        }
Пример #7
0
        public float[] DrawOn(Page page)
        {
            this.xText = x1;
            this.yText = y1 + font.GetAscent();
            foreach (Paragraph paragraph in paragraphs)
            {
                int           numberOfTextLines = paragraph.list.Count;
                StringBuilder buf = new StringBuilder();
                for (int i = 0; i < numberOfTextLines; i++)
                {
                    TextLine textLine = paragraph.list[i];
                    buf.Append(textLine.text);
                }
                for (int i = 0; i < numberOfTextLines; i++)
                {
                    TextLine textLine = paragraph.list[i];
                    if (i == 0)
                    {
                        beginParagraphPoints.Add(new float[] { xText, yText });
                    }
                    textLine.SetAltDescription((i == 0) ? buf.ToString() : Single.space);
                    textLine.SetActualText((i == 0) ? buf.ToString() : Single.space);
                    float[] point = DrawTextLine(page, xText, yText, textLine);
                    xText = point[0];
                    if (textLine.GetTrailingSpace())
                    {
                        xText += spaceBetweenTextLines;
                    }
                    yText = point[1];
                }
                xText  = x1;
                yText += paragraphLeading;
            }

            float height = ((yText - paragraphLeading) - y1) + font.descent;

            if (page != null && drawBorder)
            {
                Box box = new Box();
                box.SetLocation(x1, y1);
                box.SetSize(width, height);
                box.DrawOn(page);
            }

            return(new float[] { x1 + width, y1 + height });
        }
Пример #8
0
        /**
         *  Draws this PlainText on the specified page.
         *
         *  @param page the page to draw on.
         *  @return x and y coordinates of the bottom right corner of this component.
         *  @throws Exception
         */
        public float[] DrawOn(Page page)
        {
            float originalSize = font.GetSize();

            font.SetSize(fontSize);
            float y_text = y + font.GetAscent();

            page.AddBMC(StructElem.SPAN, language, Single.space, Single.space);
            page.SetBrushColor(backgroundColor);
            leading = font.GetBodyHeight();
            float h = font.GetBodyHeight() * textLines.Length;

            page.FillRect(x, y, w, h);
            page.SetPenColor(borderColor);
            page.SetPenWidth(0f);
            page.DrawRect(x, y, w, h);
            page.AddEMC();

            page.AddBMC(StructElem.SPAN, language, altDescription, actualText);
            page.SetTextStart();
            page.SetTextFont(font);
            page.SetBrushColor(textColor);
            page.SetTextLeading(leading);
            page.SetTextLocation(x, y_text);
            foreach (String str in textLines)
            {
                if (font.skew15)
                {
                    SetTextSkew(page, 0.26f, x, y_text);
                }
                page.Println(str);
                endOfLinePoints.Add(new float[] { x + font.StringWidth(str), y_text });
                y_text += leading;
            }
            page.SetTextEnd();
            page.AddEMC();

            font.SetSize(originalSize);

            return(new float[] { x + w, y + h });
        }
        private TextBlock DrawText(Page page)
        {
            List <String> list = new List <String>();
            StringBuilder buf  = new StringBuilder();

            String[] lines = text.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
            foreach (String line in lines)
            {
                if (IsCJK(line))
                {
                    buf.Length = 0;
                    for (int i = 0; i < line.Length; i++)
                    {
                        Char ch = line[i];
                        if (font.StringWidth(fallbackFont, buf.ToString() + ch) < this.w)
                        {
                            buf.Append(ch);
                        }
                        else
                        {
                            list.Add(buf.ToString());
                            buf.Length = 0;
                            buf.Append(ch);
                        }
                    }
                    if (!buf.ToString().Trim().Equals(""))
                    {
                        list.Add(buf.ToString().Trim());
                    }
                }
                else
                {
                    if (font.StringWidth(fallbackFont, line) < this.w)
                    {
                        list.Add(line);
                    }
                    else
                    {
                        buf.Length = 0;
                        String[] tokens = Regex.Split(line, @"\s+");
                        foreach (String token in tokens)
                        {
                            if (font.StringWidth(fallbackFont,
                                                 buf.ToString() + " " + token) < this.w)
                            {
                                buf.Append(" " + token);
                            }
                            else
                            {
                                list.Add(buf.ToString().Trim());
                                buf.Length = 0;
                                buf.Append(token);
                            }
                        }

                        if (!buf.ToString().Trim().Equals(""))
                        {
                            list.Add(buf.ToString().Trim());
                        }
                    }
                }
            }
            lines = list.ToArray();

            float x_text;
            float y_text = y + font.GetAscent();

            for (int i = 0; i < lines.Length; i++)
            {
                if (textAlign == Align.LEFT)
                {
                    x_text = x;
                }
                else if (textAlign == Align.RIGHT)
                {
                    x_text = (x + this.w) - (font.StringWidth(fallbackFont, lines[i]));
                }
                else if (textAlign == Align.CENTER)
                {
                    x_text = x + (this.w - font.StringWidth(fallbackFont, lines[i])) / 2;
                }
                else
                {
                    throw new Exception("Invalid text alignment option.");
                }

                if (page != null)
                {
                    page.DrawString(
                        font, fallbackFont, lines[i], x_text, y_text);
                }

                if (i < (lines.Length - 1))
                {
                    y_text += font.GetBodyHeight() + space;
                }
                else
                {
                    y_text += font.GetDescent() + space;
                }
            }

            this.h = y_text - y;

            return(this);
        }
Пример #10
0
        /**
         *  Draws this CheckBox on the specified Page.
         *
         *  @param page the page to draw on.
         *  @return x and y coordinates of the bottom right corner of this component.
         *  @throws Exception
         */
        public float[] DrawOn(Page page)
        {
            page.AddBMC(StructElem.SPAN, language, altDescription, actualText);

            this.w          = font.GetAscent();
            this.h          = this.w;
            this.penWidth   = this.w / 15;
            this.checkWidth = this.w / 5;

            float yBox = y;

            page.SetPenWidth(penWidth);
            page.SetPenColor(boxColor);
            page.SetLinePattern("[] 0");
            page.DrawRect(x + this.penWidth, yBox + this.penWidth, w, h);

            if (mark == Mark.CHECK || mark == Mark.X)
            {
                page.SetPenWidth(checkWidth);
                page.SetPenColor(checkColor);
                if (mark == Mark.CHECK)
                {
                    // Draw check mark
                    page.MoveTo(x + checkWidth + penWidth, yBox + h / 2 + penWidth);
                    page.LineTo((x + w / 6 + checkWidth) + penWidth, ((yBox + h) - 4f * checkWidth / 3f) + penWidth);
                    page.LineTo(((x + w) - checkWidth) + penWidth, (yBox + checkWidth) + penWidth);
                    page.StrokePath();
                }
                else
                {
                    // Draw 'X' mark
                    page.MoveTo(x + checkWidth + penWidth, yBox + checkWidth + penWidth);
                    page.LineTo(((x + w) - checkWidth) + penWidth, ((yBox + h) - checkWidth) + penWidth);
                    page.MoveTo(((x + w) - checkWidth) + penWidth, (yBox + checkWidth) + penWidth);
                    page.LineTo((x + checkWidth) + penWidth, ((yBox + h) - checkWidth) + penWidth);
                    page.StrokePath();
                }
            }

            if (uri != null)
            {
                page.SetBrushColor(Color.blue);
            }
            page.DrawString(font, label, x + 3f * w / 2f, y + font.ascent);
            page.SetPenWidth(0f);
            page.SetPenColor(Color.black);
            page.SetBrushColor(Color.black);

            page.AddEMC();

            if (uri != null)
            {
                page.AddAnnotation(new Annotation(
                                       uri,
                                       null,
                                       x + 3f * w / 2f,
                                       y,
                                       x + 3f * w / 2f + font.StringWidth(label),
                                       y + font.bodyHeight,
                                       language,
                                       altDescription,
                                       actualText));
            }

            return(new float[] { x + 3f * w + font.StringWidth(label), y + font.bodyHeight });
        }
Пример #11
0
        public TextFrame DrawOn(Page page, bool draw)
        {
            this.x_text = x;
            this.y_text = y + font.GetAscent();

            Paragraph paragraph = null;

            for (int i = 0; i < paragraphs.Count; i++)
            {
                paragraph = paragraphs[i];

                StringBuilder buf = new StringBuilder();
                foreach (TextLine textLine in paragraph.list)
                {
                    buf.Append(textLine.GetText());
                    buf.Append(Single.space);
                }

                int numOfTextLines = paragraph.list.Count;
                for (int j = 0; j < numOfTextLines; j++)
                {
                    TextLine textLine = paragraph.list[j];
                    if (j == 0)
                    {
                        beginParagraphPoints.Add(new float[] { x_text, y_text });
                    }
                    textLine.SetAltDescription((i == 0) ? buf.ToString() : Single.space);
                    textLine.SetActualText((i == 0) ? buf.ToString() : Single.space);

                    TextLine textLine2 = DrawTextLine(page, x_text, y_text, textLine, draw);
                    if (!textLine2.GetText().Equals(""))
                    {
                        List <Paragraph> theRest    = new List <Paragraph>();
                        Paragraph        paragraph2 = new Paragraph(textLine2);
                        j++;
                        while (j < numOfTextLines)
                        {
                            paragraph2.Add(paragraph.list[j]);
                            j++;
                        }
                        theRest.Add(paragraph2);
                        i++;
                        while (i < paragraphs.Count)
                        {
                            theRest.Add(paragraphs[i]);
                            i++;
                        }
                        return(new TextFrame(theRest));
                    }

                    if (j == (numOfTextLines - 1))
                    {
                        endParagraphPoints.Add(new float[] { textLine2.x, textLine2.y });
                    }
                    x_text = textLine2.x;
                    if (textLine.GetTrailingSpace())
                    {
                        x_text += spaceBetweenTextLines;
                    }
                    y_text = textLine2.y;
                }
                x_text  = x;
                y_text += paragraphLeading;
            }

            TextFrame textFrame = new TextFrame(null);

            textFrame.SetLocation(x_text, y_text + font.GetDescent());
            return(textFrame);
        }
Пример #12
0
 private void StrikeoutText(
     Page page, Font font, String text, float x, float y)
 {
     page.AddBMC(StructElem.SPAN, Single.space, Single.space);
     page.SetPenWidth(font.underlineThickness);
     page.MoveTo(x, y - font.GetAscent()/3f);
     page.LineTo(x + font.StringWidth(text), y - font.GetAscent()/3f);
     page.StrokePath();
     page.AddEMC();
 }