Example #1
0
        /// <summary>
        /// Static method thats format a paragraph
        /// </summary>
        /// <param name="strText">Input Text</param>
        /// <param name="fontSize">Font's size</param>
        /// <param name="fontType">Font's type</param>
        /// <param name="parWidth">Paragrapfh's width</param>
        /// <param name="lineHeight">Line's height</param>
        /// <param name="parAlign">Paragraph's Alignment</param>
        /// <returns>IEnumerable interface that cointains paragraphLine objects</returns>
        public static IEnumerable formatParagraph(string strText, int fontSize, predefinedFont fontType, int parWidth, int lineHeight, predefinedAlignment parAlign)
        {
            string[]      paragraphsArray = strText.Split("\n".ToCharArray());
            string[]      bufferArray;
            int           lineLength;
            paragraphLine tempPar;
            StringBuilder lineString  = new StringBuilder(parWidth);
            ArrayList     resultArray = new ArrayList();

            lineLength = 0;
            foreach (string paragraph in paragraphsArray)
            {
                bufferArray = paragraph.Split(" ".ToCharArray());
                foreach (string word in bufferArray)
                {
                    if ((textAdapter.wordWeight(word + " ", fontSize, fontType) + lineLength) > parWidth)
                    {
                        switch (parAlign)
                        {
                        case predefinedAlignment.csLeft:
                        default:
                            tempPar = new paragraphLine(lineString.ToString(0, lineString.Length - 1), lineHeight, 0);
                            break;

                        case predefinedAlignment.csRight:
                            tempPar = new paragraphLine(lineString.ToString(0, lineString.Length - 1), lineHeight, parWidth - lineLength);
                            break;

                        case predefinedAlignment.csCenter:
                            tempPar = new paragraphLine(lineString.ToString(0, lineString.Length - 1), lineHeight, Convert.ToInt32((parWidth - lineLength) / 2));
                            break;
                        }
                        resultArray.Add(tempPar);
                        lineString.Remove(0, lineString.Length);
                        lineLength = 0;
                    }
                    lineString.Append(word + " ");
                    lineLength += textAdapter.wordWeight(word + " ", fontSize, fontType);
                }
                if (lineLength > 0)
                {
                    switch (parAlign)
                    {
                    case predefinedAlignment.csLeft:
                    default:
                        tempPar = new paragraphLine(lineString.ToString(0, lineString.Length - 1), lineHeight, 0);
                        break;

                    case predefinedAlignment.csRight:
                        tempPar = new paragraphLine(lineString.ToString(0, lineString.Length - 1), lineHeight, parWidth - lineLength);
                        break;

                    case predefinedAlignment.csCenter:
                        tempPar = new paragraphLine(lineString.ToString(0, lineString.Length - 1), lineHeight, Convert.ToInt32((parWidth - lineLength) / 2));
                        break;
                    }
                    resultArray.Add(tempPar);
                    lineString.Remove(0, lineString.Length);
                    lineLength = 0;
                }
                bufferArray = null;
            }
            return(resultArray);
        }
Example #2
0
        /// <summary>
        /// Method that adds a paragraph to the page object
        /// </summary>
        /// <param name="newText">Text</param>
        /// <param name="x">X position of the text in the page</param>
        /// <param name="y">Y position of the text in the page</param>
        /// <param name="fontType">Font's type</param>
        /// <param name="fontSize">Font's size</param>
        /// <param name="parWidth">Paragraph's width</param>
        /// <param name="lineHeight">Line's height</param>
        /// <param name="parAlign">Paragraph's alignment</param>
        /// <param name="fontColor">Font's color</param>
        public void addParagraph(string newText, int x, int y, predefinedFont fontType, int fontSize, int parWidth, int lineHeight, predefinedAlignment parAlign, predefinedColor fontColor)
        {
            paragraphElement objParagraph = new paragraphElement(textAdapter.formatParagraph(newText, fontSize, fontType, parWidth, lineHeight, parAlign), fontSize, fontType, x, y, fontColor);

            _elements.Add(objParagraph);
            objParagraph = null;
        }
 /// <summary>
 /// Static method thats format a paragraph
 /// </summary>
 /// <param name="strText">Input Text</param>
 /// <param name="fontSize">Font's size</param>
 /// <param name="fontType">Font's type</param>
 /// <param name="parWidth">Paragrapfh's width</param>
 /// <param name="lineHeight">Line's height</param>
 /// <param name="parAlign">Paragraph's Alignment</param>
 /// <returns>IEnumerable interface that cointains paragraphLine objects</returns>
 public static IEnumerable formatParagraph(string strText,int fontSize,predefinedFont fontType,int parWidth,int lineHeight,predefinedAlignment parAlign)
 {
     string[] paragraphsArray = strText.Split("\n".ToCharArray());
     string[] bufferArray;
     int lineLength;
     paragraphLine tempPar;
     StringBuilder lineString = new StringBuilder(parWidth);
     ArrayList resultArray = new ArrayList();
     lineLength = 0;
     foreach(string paragraph in paragraphsArray) {
         bufferArray = paragraph.Split(" ".ToCharArray());
         foreach(string word in bufferArray) {
             if ((textAdapter.wordWeight(word + " ",fontSize,fontType) + lineLength) > parWidth) {
                 switch (parAlign) {
                     case predefinedAlignment.csLeft: default:
                         tempPar = new paragraphLine(lineString.ToString(0,lineString.Length - 1),lineHeight,0);
                         break;
                     case predefinedAlignment.csRight:
                         tempPar = new paragraphLine(lineString.ToString(0,lineString.Length - 1),lineHeight,parWidth - lineLength);
                         break;
                     case predefinedAlignment.csCenter:
                         tempPar = new paragraphLine(lineString.ToString(0,lineString.Length - 1),lineHeight,Convert.ToInt32((parWidth - lineLength) / 2));
                         break;
                 }
                 resultArray.Add(tempPar);
                 lineString.Remove(0,lineString.Length);
                 lineLength = 0;
             }
             lineString.Append(word + " ");
             lineLength += textAdapter.wordWeight(word + " ",fontSize,fontType);
         }
         if (lineLength > 0) {
             switch (parAlign) {
                 case predefinedAlignment.csLeft: default:
                     tempPar = new paragraphLine(lineString.ToString(0,lineString.Length - 1),lineHeight,0);
                     break;
                 case predefinedAlignment.csRight:
                     tempPar = new paragraphLine(lineString.ToString(0,lineString.Length - 1),lineHeight,parWidth - lineLength);
                     break;
                 case predefinedAlignment.csCenter:
                     tempPar = new paragraphLine(lineString.ToString(0,lineString.Length - 1),lineHeight,Convert.ToInt32((parWidth - lineLength) / 2));
                     break;
             }
             resultArray.Add(tempPar);
             lineString.Remove(0,lineString.Length);
             lineLength = 0;
         }
         bufferArray = null;
     }
     return resultArray;
 }
Example #4
0
 /// <summary>
 /// Method that adds a paragraph to the page object
 /// </summary>
 /// <param name="newText">Text</param>
 /// <param name="x">X position of the text in the page</param>
 /// <param name="y">Y position of the text in the page</param>
 /// <param name="fontType">Font's type</param>
 /// <param name="fontSize">Font's size</param>
 /// <param name="parWidth">Paragraph's width</param>
 /// <param name="lineHeight">Line's height</param>
 /// <param name="parAlign">Paragraph's alignment</param>
 /// <param name="fontColor">Font's color</param>
 public void addParagraph(string newText, int x, int y, predefinedFont fontType, int fontSize, int parWidth, int lineHeight, predefinedAlignment parAlign, predefinedColor fontColor)
 {
     paragraphElement objParagraph = new paragraphElement(textAdapter.formatParagraph(newText, fontSize, fontType, parWidth, lineHeight, parAlign), fontSize, fontType, x, y, fontColor);
     _elements.Add(objParagraph);
     objParagraph = null;
 }
Example #5
0
 /// <summary>
 /// Class's constructor
 /// </summary>
 /// <param name="columnValue">Text value of the column</param>
 /// <param name="columnAlign">Alignment of the column</param>
 /// <param name="columnSize">Size of the column</param>
 public pdfTableColumn(string columnValue, predefinedAlignment columnAlign, int columnSize)
 {
     _columnValue = columnValue;
     _columnAlign = columnAlign;
     _columnSize  = columnSize;
 }
Example #6
0
 /// <summary>
 /// Class's constructor
 /// </summary>
 /// <param name="columnValue">Text value of the column</param>
 /// <param name="columnAlign">Alignment of the column</param>
 /// <param name="columnSize">Size of the column</param>
 public pdfTableColumn(string columnValue, predefinedAlignment columnAlign, int columnSize)
 {
     _columnValue = columnValue;
     _columnAlign = columnAlign;
     _columnSize = columnSize;
 }