Example #1
0
        private void DrawBorders(
            Page page,
            float x,
            float y,
            float cell_w,
            float cell_h)
        {
            page.SetPenColor(pen);
            page.SetPenWidth(lineWidth);

            if (GetBorder(Border.TOP) &&
                GetBorder(Border.BOTTOM) &&
                GetBorder(Border.LEFT) &&
                GetBorder(Border.RIGHT))
            {
                page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                page.DrawRect(x, y, cell_w, cell_h);
                page.AddEMC();
            }
            else
            {
                float qWidth = lineWidth / 4;
                if (GetBorder(Border.TOP))
                {
                    page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                    page.MoveTo(x - qWidth, y);
                    page.LineTo(x + cell_w, y);
                    page.StrokePath();
                    page.AddEMC();
                }
                if (GetBorder(Border.BOTTOM))
                {
                    page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                    page.MoveTo(x - qWidth, y + cell_h);
                    page.LineTo(x + cell_w, y + cell_h);
                    page.StrokePath();
                    page.AddEMC();
                }
                if (GetBorder(Border.LEFT))
                {
                    page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                    page.MoveTo(x, y - qWidth);
                    page.LineTo(x, y + cell_h + qWidth);
                    page.StrokePath();
                    page.AddEMC();
                }
                if (GetBorder(Border.RIGHT))
                {
                    page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                    page.MoveTo(x + cell_w, y - qWidth);
                    page.LineTo(x + cell_w, y + cell_h + qWidth);
                    page.StrokePath();
                    page.AddEMC();
                }
            }
        }
Example #2
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();
 }
Example #3
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 });
        }
Example #4
0
        private void UnderlineText(
            Page page, Font font, String text, float x, float y)
        {
            float descent = font.GetDescent();

            page.AddBMC(StructElem.SPAN, Single.space, Single.space);
            page.SetPenWidth(font.underlineThickness);
            page.MoveTo(x, y + descent);
            page.LineTo(x + font.StringWidth(text), y + descent);
            page.StrokePath();
            page.AddEMC();
        }
Example #5
0
 /**
  *  Draws this line on the specified page.
  *
  *  @param page the page to draw this line on.
  */
 public void DrawOn(Page page)
 {
     page.SetPenColor(color);
     page.SetPenWidth(width);
     page.SetLineCapStyle(capStyle);
     page.SetLinePattern(pattern);
     page.AddBMC(StructElem.SPAN, language, altDescription, actualText);
     page.DrawLine(
         x1 + box_x,
         y1 + box_y,
         x2 + box_x,
         y2 + box_y);
     page.AddEMC();
 }
Example #6
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() });
        }
Example #7
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 });
        }
Example #8
0
        /**
         *  Draws this box 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);
            page.SetPenWidth(width);
            page.SetLinePattern(pattern);
            if (fillShape)
            {
                page.SetBrushColor(color);
            }
            else
            {
                page.SetPenColor(color);
            }
            page.MoveTo(x, y);
            page.LineTo(x + w, y);
            page.LineTo(x + w, y + h);
            page.LineTo(x, y + h);
            if (fillShape)
            {
                page.FillPath();
            }
            else
            {
                page.ClosePath();
            }
            page.AddEMC();

            if (uri != null || key != null)
            {
                page.AddAnnotation(new Annotation(
                                       uri,
                                       key, // The destination name
                                       x,
                                       y,
                                       x + w,
                                       y + h,
                                       language,
                                       altDescription,
                                       actualText));
            }

            return(new float[] { x + w, y + h + width });
        }
        /**
         *  Draws this line 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.SetPenColor(color);
            page.SetPenWidth(width);
            page.SetLineCapStyle(capStyle);
            page.SetLinePattern(pattern);
            page.AddBMC(StructElem.SPAN, language, altDescription, actualText);
            page.DrawLine(
                x1 + box_x,
                y1 + box_y,
                x2 + box_x,
                y2 + box_y);
            page.AddEMC();

            float x_max = Math.Max(x1 + box_x, x2 + box_x);
            float y_max = Math.Max(y1 + box_y, y2 + box_y);

            return(new float[] { x_max, y_max });
        }
Example #10
0
        /**
         *  Draws this box on the specified page.
         *
         *  @param page the page to draw this box on.
         */
        public void DrawOn(Page page)
        {
            page.AddBMC(StructElem.SPAN, language, altDescription, actualText);
            page.SetPenWidth(width);
            page.SetLinePattern(pattern);
            if (fill_shape) {
            page.SetBrushColor(color);
            }
            else {
            page.SetPenColor(color);
            }
            page.MoveTo(x, y);
            page.LineTo(x + w, y);
            page.LineTo(x + w, y + h);
            page.LineTo(x, y + h);
            if (fill_shape) {
            page.FillPath();
            }
            else {
            page.ClosePath();
            }
            page.AddEMC();

            if (uri != null || key != null) {
            page.AddAnnotation(new Annotation(
                    uri,
                    key,    // The destination name
                    x,
                    page.height - y,
                    x + w,
                    page.height - (y + h),
                    language,
                    altDescription,
                    actualText));
            }
        }
Example #11
0
        /**
         *  Draws this text line on the specified page if the draw parameter is true.
         *
         *  @param page the page to draw this text line on.
         *  @param draw if draw is false - no action is performed.
         *  @return x and y coordinates of the bottom right corner of this component.
         *  @throws Exception
         */
        internal float[] DrawOn(Page page, bool draw)
        {
            if (page == null || !draw || str == null || str.Equals(""))
            {
                return(new float[] { x, y });
            }

            page.SetTextDirection(degrees);

            x += box_x;
            y += box_y;

            page.SetBrushColor(color);
            page.AddBMC(StructElem.SPAN, language, altDescription, actualText);
            if (fallbackFont == null)
            {
                page.DrawString(font, str, x, y);
            }
            else
            {
                page.DrawString(font, fallbackFont, str, x, y);
            }
            page.AddEMC();

            double radians = Math.PI * degrees / 180.0;

            if (underline)
            {
                page.SetPenWidth(font.underlineThickness);
                page.SetPenColor(color);
                double lineLength = font.StringWidth(str);
                double x_adjust   = font.underlinePosition * Math.Sin(radians) + verticalOffset;
                double y_adjust   = font.underlinePosition * Math.Cos(radians) + verticalOffset;
                double x2         = x + lineLength * Math.Cos(radians);
                double y2         = y - lineLength * Math.Sin(radians);
                page.AddBMC(StructElem.SPAN, language, underlineTTS, underlineTTS);
                page.MoveTo(x + x_adjust, y + y_adjust);
                page.LineTo(x2 + x_adjust, y2 + y_adjust);
                page.StrokePath();
                page.AddEMC();
            }

            if (strikeout)
            {
                page.SetPenWidth(font.underlineThickness);
                page.SetPenColor(color);
                double lineLength = font.StringWidth(str);
                double x_adjust   = (font.body_height / 4.0) * Math.Sin(radians);
                double y_adjust   = (font.body_height / 4.0) * Math.Cos(radians);
                double x2         = x + lineLength * Math.Cos(radians);
                double y2         = y - lineLength * Math.Sin(radians);
                page.AddBMC(StructElem.SPAN, language, strikeoutTTS, strikeoutTTS);
                page.MoveTo(x - x_adjust, y - y_adjust);
                page.LineTo(x2 - x_adjust, y2 - y_adjust);
                page.StrokePath();
                page.AddEMC();
            }

            if (uri != null || key != null)
            {
                page.AddAnnotation(new Annotation(
                                       uri,
                                       key, // The destination name
                                       x,
                                       page.height - (y - font.ascent),
                                       x + font.StringWidth(str),
                                       page.height - (y - font.descent),
                                       uriLanguage,
                                       uriAltDescription,
                                       uriActualText));
            }
            page.SetTextDirection(0);

            float  len   = font.StringWidth(str);
            double x_max = Math.Max((double)x, x + len * Math.Cos(radians));
            double y_max = Math.Max((double)y, y - len * Math.Sin(radians));

            return(new float[] { (float)x_max, (float)y_max });
        }
Example #12
0
        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.SetBrushColor(textColor);
            page.AddEMC();

            page.AddBMC(StructElem.SPAN, language, altDescription, actualText);
            page.SetTextStart();
            page.SetTextFont(font);
            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 };
        }
Example #13
0
 /**
  *  Draws this line on the specified page.
  *
  *  @param page the page to draw this line on.
  */
 public void DrawOn(Page page)
 {
     page.SetPenColor(color);
     page.SetPenWidth(width);
     page.SetLineCapStyle(capStyle);
     page.SetLinePattern(pattern);
     page.AddBMC(StructElem.SPAN, language, altDescription, actualText);
     page.DrawLine(
         x1 + box_x,
         y1 + box_y,
         x2 + box_x,
         y2 + box_y);
     page.AddEMC();
 }
Example #14
0
        private void DrawBorders(
            Page page,
            float x,
            float y,
            float cell_w,
            float cell_h)
        {
            page.SetPenColor(pen);
            page.SetPenWidth(lineWidth);

            if (GetBorder(Border.TOP) &&
                GetBorder(Border.BOTTOM) &&
                GetBorder(Border.LEFT) &&
                GetBorder(Border.RIGHT)) {
            page.AddBMC(StructElem.SPAN, Single.space, Single.space);
            page.DrawRect(x, y, cell_w, cell_h);
            page.AddEMC();
            }
            else {
            if (GetBorder(Border.TOP)) {
                page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                page.MoveTo(x, y);
                page.LineTo(x + cell_w, y);
                page.StrokePath();
                page.AddEMC();
            }
            if (GetBorder(Border.BOTTOM)) {
                page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                page.MoveTo(x, y + cell_h);
                page.LineTo(x + cell_w, y + cell_h);
                page.StrokePath();
                page.AddEMC();
            }
            if (GetBorder(Border.LEFT)) {
                page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                page.MoveTo(x, y);
                page.LineTo(x, y + cell_h);
                page.StrokePath();
                page.AddEMC();
            }
            if (GetBorder(Border.RIGHT)) {
                page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                page.MoveTo(x + cell_w, y);
                page.LineTo(x + cell_w, y + cell_h);
                page.StrokePath();
                page.AddEMC();
            }
            }
        }
Example #15
0
 private void UnderlineText(
     Page page, Font font, String text, float x, float y)
 {
     float descent = font.GetDescent();
     page.AddBMC(StructElem.SPAN, Single.space, Single.space);
     page.SetPenWidth(font.underlineThickness);
     page.MoveTo(x, y + descent);
     page.LineTo(x + font.StringWidth(text), y + descent);
     page.StrokePath();
     page.AddEMC();
 }
Example #16
0
        /**
         *  Draws this CheckBox on the specified Page.
         *
         *  @param page the Page where the CheckBox is to be drawn.
         */
        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 y_box = y - font.GetAscent();
            page.SetPenWidth(penWidth);
            page.SetPenColor(boxColor);
            page.SetLinePattern("[] 0");
            page.DrawRect(x, y_box, 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, y_box + h/2);
                page.LineTo(x + w/6 + checkWidth, (y_box + h) - 4f*checkWidth/3f);
                page.LineTo((x + w) - checkWidth, y_box + checkWidth);
                page.StrokePath();
            }
            else {
                // Draw 'X' mark
                page.MoveTo(x + checkWidth, y_box + checkWidth);
                page.LineTo((x + w) - checkWidth, (y_box + h) - checkWidth);
                page.MoveTo((x + w) - checkWidth, y_box + checkWidth);
                page.LineTo(x + checkWidth, (y_box + h) - checkWidth);
                page.StrokePath();
            }
            }

            if (uri != null) {
            page.SetBrushColor(Color.blue);
            }
            page.DrawString(font, label, x + 3f*w/2f, y);
            page.SetPenWidth(0f);
            page.SetPenColor(Color.black);
            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 + 3f*w/2f,
                    page.height - y,
                    x + 3f*w/2f + font.StringWidth(label),
                    page.height - (y - font.GetAscent()),
                    language,
                    altDescription,
                    actualText));
            }

            return new float[] { x + 3f*w + font.StringWidth(label), y + font.GetBodyHeight() };
        }
Example #17
0
        private void DrawText(
            Page page,
            float x,
            float y,
            float cell_w)
        {
            float x_text;
            float y_text = y + font.ascent + this.top_padding;

            page.SetPenColor(pen);
            page.SetBrushColor(brush);

            if (GetTextAlignment() == Align.RIGHT) {
            if (compositeTextLine == null) {
                x_text = (x + cell_w) - (font.StringWidth(text) + this.right_padding);
                page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                page.DrawString(font, fallbackFont, text, x_text, y_text);
                page.AddEMC();
                if (GetUnderline()) {
                    UnderlineText(page, font, text, x_text, y_text);
                }
                if (GetStrikeout()) {
                    StrikeoutText(page, font, text, x_text, y_text);
                }
            }
            else {
                x_text = (x + cell_w) - (compositeTextLine.GetWidth() + this.right_padding);
                compositeTextLine.SetPosition(x_text, y_text);
                page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                compositeTextLine.DrawOn(page);
                page.AddEMC();
            }
            }
            else if (GetTextAlignment() == Align.CENTER) {
            if (compositeTextLine == null) {
                x_text = x + this.left_padding +
                        (((cell_w - (left_padding + right_padding)) - font.StringWidth(text)) / 2);
                page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                page.DrawString(font, fallbackFont, text, x_text, y_text);
                page.AddEMC();
                if (GetUnderline()) {
                    UnderlineText(page, font, text, x_text, y_text);
                }
                if (GetStrikeout()) {
                    StrikeoutText(page, font, text, x_text, y_text);
                }
            }
            else {
                x_text = x + this.left_padding +
                        (((cell_w - (left_padding + right_padding)) - compositeTextLine.GetWidth()) / 2);
                compositeTextLine.SetPosition(x_text, y_text);
                page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                compositeTextLine.DrawOn(page);
                page.AddEMC();
            }
            }
            else if (GetTextAlignment() == Align.LEFT) {
            x_text = x + this.left_padding;
            if (compositeTextLine == null) {
                page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                page.DrawString(font, fallbackFont, text, x_text, y_text);
                page.AddEMC();
                if (GetUnderline()) {
                    UnderlineText(page, font, text, x_text, y_text);
                }
                if (GetStrikeout()) {
                    StrikeoutText(page, font, text, x_text, y_text);
                }
            }
            else {
                compositeTextLine.SetPosition(x_text, y_text);
                page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                compositeTextLine.DrawOn(page);
                page.AddEMC();
            }
            }
            else {
            throw new Exception("Invalid Text Alignment!");
            }

            if (uri != null) {
            float w = (compositeTextLine != null) ?
                    compositeTextLine.GetWidth() : font.StringWidth(text);
            // Please note: The font descent is a negative number.
            page.AddAnnotation(new Annotation(
                    uri,
                    null,
                    x_text,
                    (page.height - y_text) + font.descent,
                    x_text + w,
                    (page.height - y_text) + font.ascent,
                    null,
                    null,
                    null));
            }
        }
Example #18
0
        private void ImprovedDrawText(
            Page page,
            float x,
            float y,
            float cell_w,
            string p_text)
        {
            // verificando se precisa cortar o texto para caber dentro da célula
            string v_text;
            float v_renderedsize = font.StringWidth(p_text);
            if (v_renderedsize > cell_w)
            {
            v_text = p_text.Substring(0, (int)(((float)(cell_w * p_text.Length)) / v_renderedsize));
            v_renderedsize = font.StringWidth(v_text);
            }
            else
            v_text = p_text;

            float x_text;
            float y_text = y + font.ascent + this.top_padding;

            page.SetPenColor(pen);
            page.SetBrushColor(brush);

            if (GetTextAlignment() == Align.RIGHT) {
            if (compositeTextLine == null) {
                x_text = (x + cell_w) - (v_renderedsize + this.right_padding);
                page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                page.DrawString(font, fallbackFont, v_text, x_text, y_text);
                page.AddEMC();
                if (GetUnderline()) {
                    UnderlineText(page, font, v_text, x_text, y_text);
                }
                if (GetStrikeout()) {
                    StrikeoutText(page, font, v_text, x_text, y_text);
                }
            }
            else {
                x_text = (x + cell_w) - (v_renderedsize + this.right_padding);
                compositeTextLine.SetPosition(x_text, y_text);
                page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                compositeTextLine.DrawOn(page);
                page.AddEMC();
            }
            }
            else if (GetTextAlignment() == Align.CENTER) {
            if (compositeTextLine == null) {
                x_text = x + this.left_padding +
                        (((cell_w - (left_padding + right_padding)) - v_renderedsize) / 2);
                page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                page.DrawString(font, fallbackFont, v_text, x_text, y_text);
                page.AddEMC();
                if (GetUnderline()) {
                    UnderlineText(page, font, v_text, x_text, y_text);
                }
                if (GetStrikeout()) {
                    StrikeoutText(page, font, v_text, x_text, y_text);
                }
            }
            else {
                x_text = x + this.left_padding +
                        (((cell_w - (left_padding + right_padding)) - v_renderedsize) / 2);
                compositeTextLine.SetPosition(x_text, y_text);
                page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                compositeTextLine.DrawOn(page);
                page.AddEMC();
            }
            }
            else if (GetTextAlignment() == Align.LEFT) {
            x_text = x + this.left_padding;
            if (compositeTextLine == null) {
                page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                page.DrawString(font, fallbackFont, v_text, x_text, y_text);
                page.AddEMC();
                if (GetUnderline()) {
                    UnderlineText(page, font, v_text, x_text, y_text);
                }
                if (GetStrikeout()) {
                    StrikeoutText(page, font, v_text, x_text, y_text);
                }
            }
            else {
                compositeTextLine.SetPosition(x_text, y_text);
                page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                compositeTextLine.DrawOn(page);
                page.AddEMC();
            }
            }
            else {
            throw new Exception("Invalid Text Alignment!");
            }

            if (uri != null) {
            float w = (compositeTextLine != null) ?
                    compositeTextLine.GetWidth() : v_renderedsize;
            // Please note: The font descent is a negative number.
            page.AddAnnotation(new Annotation(
                    uri,
                    null,
                    x_text,
                    (page.height - y_text) + font.descent,
                    x_text + w,
                    (page.height - y_text) + font.ascent,
                    null,
                    null,
                    null));
            }
        }
Example #19
0
        /**
         *  Draws this image on the specified page.
         *
         *  @param page the page to draw this image on.
         */
        public void DrawOn(Page page)
        {
            page.AddBMC(StructElem.SPAN, language, altDescription, actualText);

            x += box_x;
            y += box_y;
            page.Append("q\n");

            if (rotate90) {
            page.Append(h);
            page.Append(' ');
            page.Append(0f);
            page.Append(' ');
            page.Append(0f);
            page.Append(' ');
            page.Append(w);
            page.Append(' ');
            page.Append(x);
            page.Append(' ');
            page.Append(page.height - y);
            page.Append(" cm\n");

            // Rotate the image 2x45 degrees clockwise. The magic number is Math.sqrt(0.5):
            page.Append("0.7071067811 -0.7071067811 0.7071067811 0.7071067811 0.0 0.0 cm\n");
            page.Append("0.7071067811 -0.7071067811 0.7071067811 0.7071067811 0.0 0.0 cm\n");
            }
            else {
            page.Append(w);
            page.Append(' ');
            page.Append(0f);
            page.Append(' ');
            page.Append(0f);
            page.Append(' ');
            page.Append(h);
            page.Append(' ');
            page.Append(x);
            page.Append(' ');
            page.Append(page.height - (y + h));
            page.Append(" cm\n");
            }

            page.Append("/Im");
            page.Append(objNumber);
            page.Append(" Do\n");
            page.Append("Q\n");

            page.AddEMC();

            if (uri != null || key != null) {
            page.AddAnnotation(new Annotation(
                    uri,
                    key,    // The destination name
                    x,
                    page.height - y,
                    x + w,
                    page.height - (y + h),
                    language,
                    altDescription,
                    actualText));
            }
        }
Example #20
0
        /**
         *  Draws this image on the specified page.
         *
         *  @param page the page to draw this image on.
         */
        public void DrawOn(Page page)
        {
            page.AddBMC(StructElem.SPAN, language, altDescription, actualText);

            x += box_x;
            y += box_y;
            page.Append("q\n");

            if (rotate90)
            {
                page.Append(h);
                page.Append(' ');
                page.Append(0f);
                page.Append(' ');
                page.Append(0f);
                page.Append(' ');
                page.Append(w);
                page.Append(' ');
                page.Append(x);
                page.Append(' ');
                page.Append(page.height - y);
                page.Append(" cm\n");

                // Rotate the image 2x45 degrees clockwise. The magic number is Math.sqrt(0.5):
                page.Append("0.7071067811 -0.7071067811 0.7071067811 0.7071067811 0.0 0.0 cm\n");
                page.Append("0.7071067811 -0.7071067811 0.7071067811 0.7071067811 0.0 0.0 cm\n");
            }
            else
            {
                page.Append(w);
                page.Append(' ');
                page.Append(0f);
                page.Append(' ');
                page.Append(0f);
                page.Append(' ');
                page.Append(h);
                page.Append(' ');
                page.Append(x);
                page.Append(' ');
                page.Append(page.height - (y + h));
                page.Append(" cm\n");
            }

            page.Append("/Im");
            page.Append(objNumber);
            page.Append(" Do\n");
            page.Append("Q\n");

            page.AddEMC();

            if (uri != null || key != null)
            {
                page.AddAnnotation(new Annotation(
                                       uri,
                                       key, // The destination name
                                       x,
                                       page.height - y,
                                       x + w,
                                       page.height - (y + h),
                                       language,
                                       altDescription,
                                       actualText));
            }
        }
Example #21
0
        /**
         *  Draws this image 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);

            x += box_x;
            y += box_y;
            page.Append("q\n");

            if (degrees == 0)
            {
                page.Append(w);
                page.Append(' ');
                page.Append(0f);
                page.Append(' ');
                page.Append(0f);
                page.Append(' ');
                page.Append(h);
                page.Append(' ');
                page.Append(x);
                page.Append(' ');
                page.Append(page.height - (y + h));
                page.Append(" cm\n");
            }
            else if (degrees == 90)
            {
                page.Append(h);
                page.Append(' ');
                page.Append(0f);
                page.Append(' ');
                page.Append(0f);
                page.Append(' ');
                page.Append(w);
                page.Append(' ');
                page.Append(x);
                page.Append(' ');
                page.Append(page.height - y);
                page.Append(" cm\n");
                page.Append("0 -1 1 0 0 0 cm\n");
            }
            else if (degrees == 180)
            {
                page.Append(w);
                page.Append(' ');
                page.Append(0f);
                page.Append(' ');
                page.Append(0f);
                page.Append(' ');
                page.Append(h);
                page.Append(' ');
                page.Append(x + w);
                page.Append(' ');
                page.Append(page.height - y);
                page.Append(" cm\n");
                page.Append("-1 0 0 -1 0 0 cm\n");
            }
            else if (degrees == 270)
            {
                page.Append(h);
                page.Append(' ');
                page.Append(0f);
                page.Append(' ');
                page.Append(0f);
                page.Append(' ');
                page.Append(w);
                page.Append(' ');
                page.Append(x + h);
                page.Append(' ');
                page.Append(page.height - (y + w));
                page.Append(" cm\n");
                page.Append("0 1 -1 0 0 0 cm\n");
            }

            if (flipUpsideDown)
            {
                page.Append("1 0 0 -1 0 0 cm\n");
            }

            page.Append("/Im");
            page.Append(objNumber);
            page.Append(" Do\n");
            page.Append("Q\n");

            page.AddEMC();

            if (uri != null || key != null)
            {
                page.AddAnnotation(new Annotation(
                                       uri,
                                       key, // The destination name
                                       x,
                                       page.height - y,
                                       x + w,
                                       page.height - (y + h),
                                       language,
                                       altDescription,
                                       actualText));
            }

            return(new float[] { x + w, y + h });
        }
Example #22
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() };
        }
Example #23
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();
 }
Example #24
0
        private void DrawText(
            Page page,
            float x,
            float y,
            float cell_w,
            float cell_h)
        {
            float x_text;
            float y_text;

            if (valign == Align.TOP)
            {
                y_text = y + font.ascent + this.top_padding;
            }
            else if (valign == Align.CENTER)
            {
                y_text = y + cell_h / 2 + font.ascent / 2;
            }
            else if (valign == Align.BOTTOM)
            {
                y_text = (y + cell_h) - this.bottom_padding;
            }
            else
            {
                throw new Exception("Invalid vertical text alignment option.");
            }

            page.SetPenColor(pen);
            page.SetBrushColor(brush);

            if (GetTextAlignment() == Align.RIGHT)
            {
                if (compositeTextLine == null)
                {
                    x_text = (x + cell_w) - (font.StringWidth(text) + this.right_padding);
                    page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                    page.DrawString(font, fallbackFont, text, x_text, y_text);
                    page.AddEMC();
                    if (GetUnderline())
                    {
                        UnderlineText(page, font, text, x_text, y_text);
                    }
                    if (GetStrikeout())
                    {
                        StrikeoutText(page, font, text, x_text, y_text);
                    }
                }
                else
                {
                    x_text = (x + cell_w) - (compositeTextLine.GetWidth() + this.right_padding);
                    compositeTextLine.SetLocation(x_text, y_text);
                    page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                    compositeTextLine.DrawOn(page);
                    page.AddEMC();
                }
            }
            else if (GetTextAlignment() == Align.CENTER)
            {
                if (compositeTextLine == null)
                {
                    x_text = x + this.left_padding +
                             (((cell_w - (left_padding + right_padding)) - font.StringWidth(text)) / 2);
                    page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                    page.DrawString(font, fallbackFont, text, x_text, y_text);
                    page.AddEMC();
                    if (GetUnderline())
                    {
                        UnderlineText(page, font, text, x_text, y_text);
                    }
                    if (GetStrikeout())
                    {
                        StrikeoutText(page, font, text, x_text, y_text);
                    }
                }
                else
                {
                    x_text = x + this.left_padding +
                             (((cell_w - (left_padding + right_padding)) - compositeTextLine.GetWidth()) / 2);
                    compositeTextLine.SetLocation(x_text, y_text);
                    page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                    compositeTextLine.DrawOn(page);
                    page.AddEMC();
                }
            }
            else if (GetTextAlignment() == Align.LEFT)
            {
                x_text = x + this.left_padding;
                if (compositeTextLine == null)
                {
                    page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                    page.DrawString(font, fallbackFont, text, x_text, y_text);
                    page.AddEMC();
                    if (GetUnderline())
                    {
                        UnderlineText(page, font, text, x_text, y_text);
                    }
                    if (GetStrikeout())
                    {
                        StrikeoutText(page, font, text, x_text, y_text);
                    }
                }
                else
                {
                    compositeTextLine.SetLocation(x_text, y_text);
                    page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                    compositeTextLine.DrawOn(page);
                    page.AddEMC();
                }
            }
            else
            {
                throw new Exception("Invalid Text Alignment!");
            }

            if (uri != null)
            {
                float w = (compositeTextLine != null) ?
                          compositeTextLine.GetWidth() : font.StringWidth(text);
                // Please note: The font descent is a negative number.
                page.AddAnnotation(new Annotation(
                                       uri,
                                       null,
                                       x_text,
                                       (page.height - y_text) + font.descent,
                                       x_text + w,
                                       (page.height - y_text) + font.ascent,
                                       null,
                                       null,
                                       null));
            }
        }
Example #25
0
        private void ImprovedDrawText(
            Page page,
            float x,
            float y,
            float cell_w,
            string p_text)
        {
            // verificando se precisa cortar o texto para caber dentro da célula
            string v_text;
            float  v_renderedsize = font.StringWidth(p_text);

            if (v_renderedsize > cell_w)
            {
                v_text         = p_text.Substring(0, (int)(((float)(cell_w * p_text.Length)) / v_renderedsize));
                v_renderedsize = font.StringWidth(v_text);
            }
            else
            {
                v_text = p_text;
            }

            float x_text;
            float y_text = y + font.ascent + this.top_padding;

            page.SetPenColor(pen);
            page.SetBrushColor(brush);

            if (GetTextAlignment() == Align.RIGHT)
            {
                if (compositeTextLine == null)
                {
                    x_text = (x + cell_w) - (v_renderedsize + this.right_padding);
                    page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                    page.DrawString(font, fallbackFont, v_text, x_text, y_text);
                    page.AddEMC();
                    if (GetUnderline())
                    {
                        UnderlineText(page, font, v_text, x_text, y_text);
                    }
                    if (GetStrikeout())
                    {
                        StrikeoutText(page, font, v_text, x_text, y_text);
                    }
                }
                else
                {
                    x_text = (x + cell_w) - (v_renderedsize + this.right_padding);
                    compositeTextLine.SetPosition(x_text, y_text);
                    page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                    compositeTextLine.DrawOn(page);
                    page.AddEMC();
                }
            }
            else if (GetTextAlignment() == Align.CENTER)
            {
                if (compositeTextLine == null)
                {
                    x_text = x + this.left_padding +
                             (((cell_w - (left_padding + right_padding)) - v_renderedsize) / 2);
                    page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                    page.DrawString(font, fallbackFont, v_text, x_text, y_text);
                    page.AddEMC();
                    if (GetUnderline())
                    {
                        UnderlineText(page, font, v_text, x_text, y_text);
                    }
                    if (GetStrikeout())
                    {
                        StrikeoutText(page, font, v_text, x_text, y_text);
                    }
                }
                else
                {
                    x_text = x + this.left_padding +
                             (((cell_w - (left_padding + right_padding)) - v_renderedsize) / 2);
                    compositeTextLine.SetPosition(x_text, y_text);
                    page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                    compositeTextLine.DrawOn(page);
                    page.AddEMC();
                }
            }
            else if (GetTextAlignment() == Align.LEFT)
            {
                x_text = x + this.left_padding;
                if (compositeTextLine == null)
                {
                    page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                    page.DrawString(font, fallbackFont, v_text, x_text, y_text);
                    page.AddEMC();
                    if (GetUnderline())
                    {
                        UnderlineText(page, font, v_text, x_text, y_text);
                    }
                    if (GetStrikeout())
                    {
                        StrikeoutText(page, font, v_text, x_text, y_text);
                    }
                }
                else
                {
                    compositeTextLine.SetPosition(x_text, y_text);
                    page.AddBMC(StructElem.SPAN, Single.space, Single.space);
                    compositeTextLine.DrawOn(page);
                    page.AddEMC();
                }
            }
            else
            {
                throw new Exception("Invalid Text Alignment!");
            }

            if (uri != null)
            {
                float w = (compositeTextLine != null) ?
                          compositeTextLine.GetWidth() : v_renderedsize;
                // Please note: The font descent is a negative number.
                page.AddAnnotation(new Annotation(
                                       uri,
                                       null,
                                       x_text,
                                       (page.height - y_text) + font.descent,
                                       x_text + w,
                                       (page.height - y_text) + font.ascent,
                                       null,
                                       null,
                                       null));
            }
        }
Example #26
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 });
        }
Example #27
0
        /**
         *  Draws this text line on the specified page if the draw parameter is true.
         *
         *  @param page the page to draw this text line on.
         *  @param draw if draw is false - no action is performed.
         */
        internal void DrawOn(Page page, bool draw)
        {
            if (page == null || !draw || str == null || str.Equals("")) return;

            page.SetTextDirection(degrees);

            x += box_x;
            y += box_y;

            page.SetBrushColor(color);
            page.AddBMC(StructElem.SPAN, language, altDescription, actualText);
            if (fallbackFont == null) {
            page.DrawString(font, str, x, y);
            }
            else {
            page.DrawString(font, fallbackFont, str, x, y);
            }
            page.AddEMC();

            if (underline) {
            page.SetPenWidth(font.underlineThickness);
            page.SetPenColor(color);
            double lineLength = font.StringWidth(str);
            double radians = Math.PI * degrees / 180.0;
            double x_adjust = font.underlinePosition * Math.Sin(radians);
            double y_adjust = font.underlinePosition * Math.Cos(radians);
            double x2 = x + lineLength * Math.Cos(radians);
            double y2 = y - lineLength * Math.Sin(radians);
            page.AddBMC(StructElem.SPAN, language, underlineTTS, underlineTTS);
            page.MoveTo(x + x_adjust, y + y_adjust);
            page.LineTo(x2 + x_adjust, y2 + y_adjust);
            page.StrokePath();
            page.AddEMC();
            }

            if (strikeout) {
            page.SetPenWidth(font.underlineThickness);
            page.SetPenColor(color);
            double lineLength = font.StringWidth(str);
            double radians = Math.PI * degrees / 180.0;
            double x_adjust = ( font.body_height / 4.0 ) * Math.Sin(radians);
            double y_adjust = ( font.body_height / 4.0 ) * Math.Cos(radians);
            double x2 = x + lineLength * Math.Cos(radians);
            double y2 = y - lineLength * Math.Sin(radians);
            page.AddBMC(StructElem.SPAN, language, strikeoutTTS, strikeoutTTS);
            page.MoveTo(x - x_adjust, y - y_adjust);
            page.LineTo(x2 - x_adjust, y2 - y_adjust);
            page.StrokePath();
            page.AddEMC();
            }

            if (uri != null || key != null) {
            page.AddAnnotation(new Annotation(
                    uri,
                    key,    // The destination name
                    x,
                    page.height - (y - font.ascent),
                    x + font.StringWidth(str),
                    page.height - (y - font.descent),
                    uriLanguage,
                    uriAltDescription,
                    uriActualText));
            }

            page.SetTextDirection(0);
        }