Ejemplo n.º 1
0
        private void LayerText(StringBuilder Page, TextObject obj)
        {
            float top = 0;

            if (obj.VertAlign != VertAlign.Top)
            {
                using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
                    using (Font f = new Font(obj.Font.Name, obj.Font.Size, obj.Font.Style))
                    {
                        RectangleF           textRect  = new RectangleF(obj.AbsLeft, obj.AbsTop, obj.Width, obj.Height);
                        StringFormat         format    = obj.GetStringFormat(Report.GraphicCache, 0);
                        Brush                textBrush = Report.GraphicCache.GetBrush(obj.TextColor);
                        AdvancedTextRenderer renderer  = new AdvancedTextRenderer(obj.Text, g, f, textBrush,
                                                                                  textRect, format, obj.HorzAlign, obj.VertAlign, obj.LineHeight, obj.Angle, obj.FontWidthRatio,
                                                                                  obj.ForceJustify, obj.Wysiwyg, obj.HtmlTags, false);
                        if (renderer.Paragraphs.Count > 0)
                        {
                            if (renderer.Paragraphs[0].Lines.Count > 0)
                            {
                                top = renderer.Paragraphs[0].Lines[0].Top - obj.AbsTop;
                            }
                        }
                    }
            }

            LayerBack(Page, obj,
                      GetSpanText(ExportUtils.HtmlString(obj.Text, obj.HtmlTags),
                                  top + obj.Padding.Top,
                                  obj.Width - obj.Padding.Horizontal,
                                  obj.Padding));
        }
Ejemplo n.º 2
0
        private int GetTable(StringBuilder Page, ExportMatrix FMatrix, int PageNumber, int CurrentPage, int ImagesCount)
        {
            for (int y = 0; y < FMatrix.Height - 1; y++)
            {
                int drow = (int)Math.Round((FMatrix.YPosById(y + 1) - FMatrix.YPosById(y)));
                if (drow == 0)
                {
                    drow = 1;
                }
                Page.Append("<tr style=\"height:").Append(SizeValue(drow, FMatrix.MaxHeight, FHeightUnits)).AppendLine("\">");
                for (int x = 0; x < FMatrix.Width - 1; x++)
                {
                    int i = FMatrix.Cell(x, y);
                    if (i != -1)
                    {
                        ExportIEMObject obj = FMatrix.ObjectById(i);
                        if (obj.Counter == 0)
                        {
                            int fx, fy, dx, dy;
                            FMatrix.ObjectPos(i, out fx, out fy, out dx, out dy);
                            obj.Counter = 1;
                            Page.Append("<td").
                            Append((dx > 1 ? " colspan=\"" + dx.ToString() + "\"" : String.Empty)).
                            Append((dy > 1 ? " rowspan=\"" + dy.ToString() + "\"" : String.Empty)).
                            Append(" class=\"").Append(FStylePrefix).Append("s").Append(obj.StyleIndex.ToString()).
                            Append("\"");
                            StringBuilder style = new StringBuilder(256);
                            if (obj.Text.Length == 0)
                            {
                                style.Append("font-size:1px;");
                            }
                            if (obj.PictureStream != null && obj.IsText)
                            {
                                style.Append("background-image: url(").
                                Append(HTMLGetImage(PageNumber, CurrentPage, ImagesCount++, obj.Hash, obj.Base, obj.Metafile, obj.PictureStream)).
                                Append(");");
                            }
                            if (style.Length > 0)
                            {
                                Page.Append(" style=\"").Append(style).Append("\"");
                            }
                            Page.Append(">");

                            // TEXT
                            if (obj.IsText)
                            {
                                if (obj.Text.Length > 0)
                                {
                                    if (!String.IsNullOrEmpty(obj.URL))
                                    {
                                        Page.Append("<a href=\"" + obj.URL + "\">");
                                    }
                                    Page.Append(ExportUtils.HtmlString(obj.Text, obj.HtmlTags));
                                    if (!String.IsNullOrEmpty(obj.URL))
                                    {
                                        Page.Append("</a>");
                                    }
                                }
                                else
                                {
                                    Page.Append(NBSP);
                                }
                            }
                            else
                            {
                                Page.Append(HTMLSaveImage(obj, PageNumber, CurrentPage, ImagesCount++));
                            }

                            Page.AppendLine("</td>");
                        }
                    }
                    else
                    {
                        Page.AppendLine("</td>");
                    }
                }
                Page.AppendLine("</tr>");
            }
            return(ImagesCount);
        }
Ejemplo n.º 3
0
        private void LayerText(FastString Page, TextObject obj)
        {
            float top = 0;

            switch (obj.TextRenderType)
            {
            case TextRenderType.HtmlParagraph:


                HtmlTextRenderer htmlTextRenderer = obj.GetHtmlTextRenderer(Zoom, Zoom);


                if (obj.VertAlign == VertAlign.Center)
                {
                    top = (obj.Height - htmlTextRenderer.CalcHeight()) / 2;
                }
                else if (obj.VertAlign == VertAlign.Bottom)
                {
                    top = obj.Height - htmlTextRenderer.CalcHeight();
                }
                FastString sb = GetHtmlParagraph(htmlTextRenderer);

                LayerBack(Page, obj,
                          GetSpanText(obj, sb,
                                      top + obj.Padding.Top,
                                      obj.Width - obj.Padding.Horizontal,
                                      obj.ParagraphOffset));
                break;

            default:
                if (obj.VertAlign != VertAlign.Top)
                {
                    Graphics g = htmlMeasureGraphics;
                    using (Font f = new Font(obj.Font.Name, obj.Font.Size, obj.Font.Style))
                    {
                        RectangleF           textRect  = new RectangleF(obj.AbsLeft, obj.AbsTop, obj.Width, obj.Height);
                        StringFormat         format    = obj.GetStringFormat(Report.GraphicCache, 0);
                        Brush                textBrush = Report.GraphicCache.GetBrush(obj.TextColor);
                        AdvancedTextRenderer renderer  = new AdvancedTextRenderer(obj.Text, g, f, textBrush, null,
                                                                                  textRect, format, obj.HorzAlign, obj.VertAlign, obj.LineHeight, obj.Angle, obj.FontWidthRatio,
                                                                                  obj.ForceJustify, obj.Wysiwyg, obj.HasHtmlTags, false, Zoom, Zoom, obj.InlineImageCache);
                        if (renderer.Paragraphs.Count > 0)
                        {
                            if (renderer.Paragraphs[0].Lines.Count > 0)
                            {
                                float height = renderer.Paragraphs[0].Lines[0].CalcHeight();
                                if (height > obj.Height)
                                {
                                    top = -(height - obj.Height) / 2;
                                }
                                else
                                {
                                    top = renderer.Paragraphs[0].Lines[0].Top - obj.AbsTop;
                                }
                            }
                        }
                    }
                }

                LayerBack(Page, obj,
                          GetSpanText(obj, ExportUtils.HtmlString(obj.Text, obj.TextRenderType),
                                      top + obj.Padding.Top,
                                      obj.Width - obj.Padding.Horizontal,
                                      obj.ParagraphOffset));
                break;
            }
        }
Ejemplo n.º 4
0
        private void LayerText(FastString Page, TextObject obj)
        {
            float top = 0;

            if (obj.Font.FontFamily.Name == "Wingdings" || obj.Font.FontFamily.Name == "Webdings")
            {
                obj.Text = WingdingsToUnicodeConverter.Convert(obj.Text);
            }

            switch (obj.TextRenderType)
            {
            case TextRenderType.HtmlParagraph:

                using (HtmlTextRenderer htmlTextRenderer = obj.GetHtmlTextRenderer(Zoom, Zoom))
                {
                    if (obj.VertAlign == VertAlign.Center)
                    {
                        top = (obj.Height - htmlTextRenderer.CalcHeight()) / 2;
                    }
                    else if (obj.VertAlign == VertAlign.Bottom)
                    {
                        top = obj.Height - htmlTextRenderer.CalcHeight();
                    }
                    FastString sb = GetHtmlParagraph(htmlTextRenderer);

                    LayerBack(Page, obj,
                              GetSpanText(obj, sb,
                                          top + obj.Padding.Top,
                                          obj.Width - obj.Padding.Horizontal,
                                          obj.ParagraphOffset));
                }
                break;

            default:
                if (obj.VertAlign != VertAlign.Top)
                {
                    IGraphics g = htmlMeasureGraphics;
                    using (Font f = new Font(obj.Font.FontFamily, obj.Font.Size * DrawUtils.ScreenDpiFX, obj.Font.Style))
                    {
                        RectangleF textRect = new RectangleF(obj.AbsLeft + obj.Padding.Left, obj.AbsTop + obj.Padding.Top,
                                                             obj.Width - obj.Padding.Left - obj.Padding.Right,
                                                             obj.Height - obj.Padding.Top - obj.Padding.Bottom);
                        StringFormat         format    = obj.GetStringFormat(Report.GraphicCache, 0);
                        Brush                textBrush = Report.GraphicCache.GetBrush(obj.TextColor);
                        AdvancedTextRenderer renderer  = new AdvancedTextRenderer(obj.Text, g, f, textBrush, null,
                                                                                  textRect, format, obj.HorzAlign, obj.VertAlign, obj.LineHeight, obj.Angle, obj.FontWidthRatio,
                                                                                  obj.ForceJustify, obj.Wysiwyg, obj.HasHtmlTags, false, Zoom, Zoom, obj.InlineImageCache);
                        if (renderer.Paragraphs.Count > 0)
                        {
                            if (renderer.Paragraphs[0].Lines.Count > 0)
                            {
                                float height = renderer.Paragraphs[0].Lines[0].CalcHeight();
                                if (height > obj.Height)
                                {
                                    top = -(height - obj.Height) / 2;
                                }
                                else
                                {
                                    top    = renderer.Paragraphs[0].Lines[0].Top - obj.AbsTop;
                                    height = renderer.CalcHeight();

                                    if (obj.VertAlign == VertAlign.Center)
                                    {
                                        top = (obj.Height - height - obj.Padding.Bottom + obj.Padding.Top) / 2;
                                    }
                                    else if (obj.VertAlign == VertAlign.Bottom)
                                    {
                                        // (float)(Math.Round(obj.Font.Size * 96 / 72) / 2
                                        // necessary to compensate for paragraph offset error in GetSpanText method below
                                        top = obj.Height - height - obj.Padding.Bottom - (float)(Math.Round(obj.Font.Size * 96 / 72) / 2);
                                    }
                                }
                            }
                        }
                    }
                }

                LayerBack(Page, obj,
                          GetSpanText(obj, ExportUtils.HtmlString(obj.Text, obj.TextRenderType, Px(Math.Round(obj.Font.Size * 96 / 72))),
                                      top,
                                      obj.Width - obj.Padding.Horizontal,
                                      obj.ParagraphOffset));
                break;
            }
        }