/// <summary>
        /// 对大文本数据以固定的高宽进行分割
        /// </summary>
        private List <string> GetPartition(string context, Font font, int enableWidth, int enableHeight)
        {
            List <string> spliteContexts = new List <string>();

            while (true)
            {
                int i = 0, m = 0, n;
                n = context.Length;
                SizeF textSizeF = new SizeF();

                while (i < n && i + 1 != n)
                {
                    m         = (i + n) / 2;
                    textSizeF = DrawUtil.MeasureString(context.Substring(0, m), font, enableWidth, graphics, report.Attributes.RowHeiht);
                    if (textSizeF.Height > enableHeight)
                    {
                        n = m;
                    }
                    else
                    {
                        i = m;
                    }
                }
                if (textSizeF.Height > enableHeight)
                {
                    m -= 1;
                }
                if (context.Length <= m + 1)
                {
                    spliteContexts.Add(context);
                    break;
                }
                else
                {
                    spliteContexts.Add(context.Substring(0, m));
                    context = context.Substring(m);
                }
            }

            return(spliteContexts);
        }
示例#2
0
 public static int GetBoundaryMM(int marge)
 {
     return(DrawUtil.PixTOMm(marge) * 10);
 }