/// <summary>
 /// Class's constructor
 /// </summary>
 public pdfTableRowStyle(predefinedFont fontType, int fontSize, pdfColor fontColor, pdfColor bgColor)
 {
     _fontType = fontType;
     _fontSize = fontSize;
     _fontColor = fontColor;
     _bgColor = bgColor;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Method that adds a text element 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="fontColor">Font's color</param>
        public void addText(string newText, int X, int Y, predefinedFont fontType, int fontSize, predefinedColor fontColor)
        {
            textElement objText = new textElement(newText, fontSize, fontType, X, Y, fontColor);

            _elements.Add(objText);
            objText = null;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Class's constructor
 /// </summary>
 public pdfTableRowStyle(predefinedFont fontType, int fontSize, predefinedColor fontColor, predefinedColor bgColor)
 {
     _fontType = fontType;
     _fontSize = fontSize;
     _fontColor = new pdfColor(fontColor);
     _bgColor = new pdfColor(bgColor);
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 5
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>
        public void addParagraph(string newText, int x, int y, predefinedFont fontType, int fontSize, int parWidth)
        {
            paragraphElement objParagraph = new paragraphElement(textAdapter.formatParagraph(newText, fontSize, fontType, parWidth), fontSize, fontType, x, y);

            _elements.Add(objParagraph);
            objParagraph = null;
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Static Mehtod that returns the name of the font
 /// </summary>
 /// <param name="fontType">Font's Type</param>
 /// <returns>String that contains the name of the font</returns>
 public static string getFontName(predefinedFont fontType)
 {
     switch (fontType)
     {
         case predefinedFont.csHelvetica:
             return "Helvetica";
         case predefinedFont.csHelveticaBold:
             return "Helvetica-Bold";
         case predefinedFont.csHelveticaOblique:
             return "Helvetica-Oblique";
         case predefinedFont.csHelvetivaBoldOblique:
             return "Helvetica-BoldOblique";
         case predefinedFont.csCourier:
             return "Courier";
         case predefinedFont.csCourierBold:
             return "Courier-Bold";
         case predefinedFont.csCourierOblique:
             return "Courier-Oblique";
         case predefinedFont.csCourierBoldOblique:
             return "Courier-BoldOblique";
         case predefinedFont.csTimes:
             return "Times-Roman";
         case predefinedFont.csTimesBold:
             return "Times-Bold";
         case predefinedFont.csTimesOblique:
             return "Times-Italic";
         case predefinedFont.csTimesBoldOblique:
             return "Times-BoldItalic";
         default:
             return "";
     }
 }
 /// <summary>
 /// Class's constructor
 /// </summary>
 public pdfTableRowStyle(predefinedFont fontType, int fontSize, pdfColor fontColor, pdfColor bgColor)
 {
     _fontType  = fontType;
     _fontSize  = fontSize;
     _fontColor = fontColor;
     _bgColor   = bgColor;
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Method that adds a text element 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>
        public void addText(string newText, int X, int Y, predefinedFont fontType, int fontSize)
        {
            textElement objText = new textElement(newText, fontSize, fontType, X, Y);

            _persistentElements.Add(objText);
            objText = null;
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Class's constructor
 /// </summary>
 public pdfTableRowStyle(predefinedFont fontType, int fontSize, predefinedColor fontColor, predefinedColor bgColor)
 {
     _fontType  = fontType;
     _fontSize  = fontSize;
     _fontColor = new pdfColor(fontColor);
     _bgColor   = new pdfColor(bgColor);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Class's constructor
 /// </summary>
 /// <param name="newContent">Text of the paragraph</param>
 /// <param name="newFontSize">Font's size</param>
 /// <param name="newFontType">Font's type</param>
 /// <param name="newCoordX">X position in the PDF document</param>
 /// <param name="newCoordY">Y position in the PDF document</param>
 public paragraphElement(IEnumerable newContent, int newFontSize, predefinedFont newFontType, int newCoordX, int newCoordY)
 {
     _content  = newContent;
     _fontSize = newFontSize;
     _fontType = newFontType;
     _coordX   = newCoordX;
     _coordY   = newCoordY;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Class's constructor
 /// </summary>
 /// <param name="newContent">Text's content</param>
 /// <param name="newFontSize">Font's size</param>
 /// <param name="newFontType">Font's type</param>
 /// <param name="newCoordX">X position of the text in the page</param>
 /// <param name="newCoordY">Y position of the text in the page</param>
 public textElement(string newContent, int newFontSize, predefinedFont newFontType, int newCoordX, int newCoordY)
 {
     _content = newContent;
     _fontSize = newFontSize;
     _fontType = newFontType;
     _coordX = newCoordX;
     _coordY = newCoordY;
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Class's constructor
 /// </summary>
 /// <param name="newContent">Text's content</param>
 /// <param name="newFontSize">Font's size</param>
 /// <param name="newFontType">Font's type</param>
 /// <param name="newCoordX">X position of the text in the page</param>
 /// <param name="newCoordY">Y position of the text in the page</param>
 public textElement(string newContent, int newFontSize, predefinedFont newFontType, int newCoordX, int newCoordY)
 {
     _content  = newContent;
     _fontSize = newFontSize;
     _fontType = newFontType;
     _coordX   = newCoordX;
     _coordY   = newCoordY;
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Class's constructor
 /// </summary>
 /// <param name="newContent">Text of the paragraph</param>
 /// <param name="newFontSize">Font's size</param>
 /// <param name="newFontType">Font's type</param>
 /// <param name="newCoordX">X position in the PDF document</param>
 /// <param name="newCoordY">Y position in the PDF document</param>
 public paragraphElement(IEnumerable newContent, int newFontSize, predefinedFont newFontType, int newCoordX, int newCoordY)
 {
     _content = newContent;
     _fontSize = newFontSize;
     _fontType = newFontType;
     _coordX = newCoordX;
     _coordY = newCoordY;
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Class's constructor
 /// </summary>
 /// <param name="newContent">Text's content</param>
 /// <param name="newFontSize">Font's size</param>
 /// <param name="newFontType">Font's type</param>
 /// <param name="newCoordX">X position of the text in the page</param>
 /// <param name="newCoordY">Y position of the text in the page</param>
 /// <param name="newStrokeColor">Font's color</param>
 public textElement(string newContent, int newFontSize, predefinedFont newFontType, int newCoordX, int newCoordY, predefinedColor newStrokeColor)
 {
     _content     = newContent;
     _fontSize    = newFontSize;
     _fontType    = newFontType;
     _coordX      = newCoordX;
     _coordY      = newCoordY;
     _strokeColor = new pdfColor(newStrokeColor);
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Class's constructor
 /// </summary>
 /// <param name="newContent">Text's content</param>
 /// <param name="newFontSize">Font's size</param>
 /// <param name="newFontType">Font's type</param>
 /// <param name="newCoordX">X position of the text in the page</param>
 /// <param name="newCoordY">Y position of the text in the page</param>
 /// <param name="newStrokeColor">Font's color</param>
 public textElement(string newContent, int newFontSize, predefinedFont newFontType, int newCoordX, int newCoordY, pdfColor newStrokeColor)
 {
     _content = newContent;
     _fontSize = newFontSize;
     _fontType = newFontType;
     _coordX = newCoordX;
     _coordY = newCoordY;
     _strokeColor = newStrokeColor;
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Class's constructor
 /// </summary>
 /// <param name="newContent">Text of the paragraph</param>
 /// <param name="newFontSize">Font's size</param>
 /// <param name="newFontType">Font's type</param>
 /// <param name="newCoordX">X position in the PDF document</param>
 /// <param name="newCoordY">Y position in the PDF document</param>
 /// <param name="newStrokeColor">Font's color</param>
 public paragraphElement(IEnumerable newContent, int newFontSize, predefinedFont newFontType, int newCoordX, int newCoordY, pdfColor newStrokeColor)
 {
     _content = newContent;
     _fontSize = newFontSize;
     _fontType = newFontType;
     _coordX = newCoordX;
     _coordY = newCoordY;
     _strokeColor = newStrokeColor;
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Class's constructor
 /// </summary>
 /// <param name="newContent">Text of the paragraph</param>
 /// <param name="newFontSize">Font's size</param>
 /// <param name="newFontType">Font's type</param>
 /// <param name="newCoordX">X position in the PDF document</param>
 /// <param name="newCoordY">Y position in the PDF document</param>
 /// <param name="newStrokeColor">Font's color</param>
 public paragraphElement(IEnumerable newContent, int newFontSize, predefinedFont newFontType, int newCoordX, int newCoordY, pdfColor newStrokeColor)
 {
     _content     = newContent;
     _fontSize    = newFontSize;
     _fontType    = newFontType;
     _coordX      = newCoordX;
     _coordY      = newCoordY;
     _strokeColor = newStrokeColor;
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Static Method that returns the lenght of a single word
        /// </summary>
        /// <param name="word">Input word</param>
        /// <param name="fontSize">Font's size</param>
        /// <param name="fontType">Font's type</param>
        /// <returns>Size of the word</returns>
        public static int wordWeight(string word, int fontSize, predefinedFont fontType)
        {
            double returnWeight = 0;

            foreach (char myChar in word.ToCharArray())
            {
                returnWeight += textAdapter.fontWeight[Convert.ToInt32(fontType) - 1][Convert.ToByte(myChar)];
            }
            return(Convert.ToInt32(returnWeight * fontSize / 1000));
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Method that adds a paragraph to the page object
 /// </summary>
 /// <param name="newText">Interface IEnumerable that contains paragraphLine objects</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="fontColor">Font's color</param>
 public void addParagraph(IEnumerable newText, int x, int y, predefinedFont fontType, int fontSize, predefinedColor fontColor)
 {
     try {
         paragraphElement objParagraph = new paragraphElement(newText, fontSize, fontType, x, y, fontColor);
         _elements.Add(objParagraph);
         objParagraph = null;
     } catch (pdfIncorrectParagraghException ex) {
         throw new pdfIncorrectParagraghException();
     }
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Method that adds a paragraph to the page object
 /// </summary>
 /// <param name="newText">Interface IEnumerable that contains paragraphLine objects</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>
 public void addParagraph(IEnumerable newText, int x, int y, predefinedFont fontType, int fontSize)
 {
     try {
         paragraphElement objParagraph = new paragraphElement(newText, fontSize, fontType, x, y);
         _persistentElements.Add(objParagraph);
         objParagraph = null;
     } catch (pdfIncorrectParagraghException ex) {
         UnityEngine.Debug.Log(ex);
         throw new pdfIncorrectParagraghException();
     }
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Static Method that crop a word to put it in a predefined space
 /// </summary>
 /// <param name="word">Input word</param>
 /// <param name="fontSize">Font's size</param>
 /// <param name="fontType">Font's type</param>
 /// <param name="textSpace">Max text's space</param>
 /// <returns>Cropped word</returns>
 public static string cropWord(string word, int fontSize, predefinedFont fontType, int textSpace)
 {
     StringBuilder tempWord = new StringBuilder();
     int i = 0;
     while ((wordWeight(tempWord.ToString(), fontSize, fontType)<= textSpace) && (i < word.Length)) {
         if ((word[i] >= 0) && (word[i] <= 255)) {
             tempWord.Append(word.ToCharArray()[i]);
         }
         i++;
     }
     if (tempWord.ToString().CompareTo(word) != 0) {
         tempWord.Remove(tempWord.Length - 3, 3);
         tempWord.Append("...");
     }
     return tempWord.ToString();
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Static Method that crop a word to put it in a predefined space
        /// </summary>
        /// <param name="word">Input word</param>
        /// <param name="fontSize">Font's size</param>
        /// <param name="fontType">Font's type</param>
        /// <param name="textSpace">Max text's space</param>
        /// <returns>Cropped word</returns>
        public static string cropWord(string word, int fontSize, predefinedFont fontType, int textSpace)
        {
            StringBuilder tempWord = new StringBuilder();
            int           i        = 0;

            while ((wordWeight(tempWord.ToString(), fontSize, fontType) <= textSpace) && (i < word.Length))
            {
                tempWord.Append(word.ToCharArray()[i]);
                i++;
            }
            if (tempWord.ToString().CompareTo(word) != 0)
            {
                tempWord.Remove(tempWord.Length - 3, 3);
                tempWord.Append("...");
            }
            return(tempWord.ToString());
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Static Mehtod that returns the name of the font
        /// </summary>
        /// <param name="fontType">Font's Type</param>
        /// <returns>String that contains the name of the font</returns>
        public static string getFontName(predefinedFont fontType)
        {
            switch (fontType)
            {
            case predefinedFont.csHelvetica:
                return("Helvetica");

            case predefinedFont.csHelveticaBold:
                return("Helvetica-Bold");

            case predefinedFont.csHelveticaOblique:
                return("Helvetica-Oblique");

            case predefinedFont.csHelvetivaBoldOblique:
                return("Helvetica-BoldOblique");

            case predefinedFont.csCourier:
                return("Courier");

            case predefinedFont.csCourierBold:
                return("Courier-Bold");

            case predefinedFont.csCourierOblique:
                return("Courier-Oblique");

            case predefinedFont.csCourierBoldOblique:
                return("Courier-BoldOblique");

            case predefinedFont.csTimes:
                return("Times-Roman");

            case predefinedFont.csTimesBold:
                return("Times-Bold");

            case predefinedFont.csTimesOblique:
                return("Times-Italic");

            case predefinedFont.csTimesBoldOblique:
                return("Times-BoldItalic");

            default:
                return("");
            }
        }
Ejemplo n.º 24
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>
 /// <returns>IEnumerable interface that cointains paragraphLine objects</returns>
 public static IEnumerable formatParagraph(string strText,int fontSize,predefinedFont fontType,int parWidth,int lineHeight)
 {
     return formatParagraph(strText,fontSize,fontType,parWidth,lineHeight,predefinedAlignment.csLeft);
 }
Ejemplo n.º 25
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);
        }
Ejemplo n.º 26
0
 /// <summary>
 /// Class's constructor
 /// </summary>
 /// <param name="newFontStyle">Font's style</param>
 /// <param name="newFontNumber">Font's number in the PDF </param>
 public pdfFont(predefinedFont newFontStyle, int newFontNumber)
 {
     _fontStyle = newFontStyle;
     _fontNumber = newFontNumber;
 }
Ejemplo n.º 27
0
 /// <summary>
 /// Class's constructor
 /// </summary>
 /// <param name="newFontStyle">Font's style</param>
 /// <param name="newFontNumber">Font's number in the PDF </param>
 public pdfFont(predefinedFont newFontStyle, int newFontNumber)
 {
     _fontStyle  = newFontStyle;
     _fontNumber = newFontNumber;
 }
Ejemplo n.º 28
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>
 public void addParagraph(string newText, int x, int y, predefinedFont fontType, int fontSize, int parWidth)
 {
     paragraphElement objParagraph = new paragraphElement(textAdapter.formatParagraph(newText, fontSize, fontType, parWidth), fontSize, fontType, x, y);
     _elements.Add(objParagraph);
     objParagraph = null;
 }
Ejemplo n.º 29
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;
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Method that adds a paragraph to the page object
 /// </summary>
 /// <param name="newText">Interface IEnumerable that contains paragraphLine objects</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="fontColor">Font's color</param>
 public void addParagraph(IEnumerable newText, int x, int y, predefinedFont fontType, int fontSize, predefinedColor fontColor)
 {
     try {
     paragraphElement objParagraph = new paragraphElement(newText, fontSize, fontType, x, y, fontColor);
     _elements.Add(objParagraph);
     objParagraph = null;
     } catch (pdfIncorrectParagraghException ex) {
         throw new pdfIncorrectParagraghException();
     }
 }
Ejemplo n.º 31
0
 /// <summary>
 /// Method that adds a text element 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="fontColor">Font's color</param>
 public void addText(string newText, int X, int Y, predefinedFont fontType, int fontSize, predefinedColor fontColor)
 {
     textElement objText = new textElement(newText, fontSize, fontType, X, Y, fontColor);
     _elements.Add(objText);
     objText = null;
 }
Ejemplo n.º 32
0
 /// <summary>
 /// Static Method that returns the lenght of a single word
 /// </summary>
 /// <param name="word">Input word</param>
 /// <param name="fontSize">Font's size</param>
 /// <param name="fontType">Font's type</param>
 /// <returns>Size of the word</returns>
 public static int wordWeight(string word,int fontSize,predefinedFont fontType)
 {
     double returnWeight = 0;
     foreach(char myChar in word.ToCharArray()) {
         if ((myChar >= 0) && (myChar <= 255)) {
             returnWeight += textAdapter.fontWeight[Convert.ToInt32(fontType) - 1][Convert.ToByte(myChar)];
         }
     }
     return Convert.ToInt32(returnWeight * fontSize /1000);
 }
Ejemplo n.º 33
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;
 }
 /// <summary>
 /// Method that adds an image to the page object
 /// </summary>
 /// <param name="newImgObject">Image Object</param>
 /// <param name="X">X position of the image in the page</param>
 /// <param name="Y">Y position of the image in the page</param>		
 //        public void addImage(Image newImgObject, int X, int Y)
 //        {
 //            try {
 //                imageElement objImage = new imageElement(newImgObject, X, Y);
 //                _persistentElements.Add(objImage);
 //                objImage = null;
 //            } catch (pdfImageNotFoundException ex) {
 //                throw new pdfImageNotFoundException(ex.Message,ex);
 //            } catch (pdfImageIOException ex) {
 //                throw new pdfImageIOException(ex.Message,ex);
 //            }
 //        }
 /// <summary>
 /// Method that adds an image to the page object
 /// </summary>
 /// <param name="newImgSource">Image's name</param>
 /// <param name="X">X position of the image in the page</param>
 /// <param name="Y">Y position of the image in the page</param>
 /// <param name="height">New height of the image</param>
 /// <param name="width">New width of the image</param>
 //        public void addImage(string newImgSource, int X, int Y, int height, int width)
 //        {
 //            try {
 //                imageElement objImage = new imageElement(newImgSource, X, Y, height, width);
 //                _persistentElements.Add(objImage);
 //                objImage = null;
 //            } catch (pdfImageNotFoundException ex) {
 //                throw new pdfImageNotFoundException(ex.Message,ex);
 //            } catch (pdfImageIOException ex) {
 //                throw new pdfImageIOException(ex.Message,ex);
 //            }
 //        }
 /// <summary>
 /// Method that adds an image to the page object
 /// </summary>
 /// <param name="newImgObject">Image Object</param>
 /// <param name="X">X position of the image in the page</param>
 /// <param name="Y">Y position of the image in the page</param>
 /// <param name="height">New height of the image</param>
 /// <param name="width">New width of the image</param>
 //        public void addImage(Image newImgObject, int X, int Y, int height, int width)
 //        {
 //            try {
 //                imageElement objImage = new imageElement(newImgObject, X, Y, height, width);
 //                _persistentElements.Add(objImage);
 //                objImage = null;
 //            } catch (pdfImageNotFoundException ex) {
 //                throw new pdfImageNotFoundException(ex.Message,ex);
 //            } catch (pdfImageIOException ex) {
 //                throw new pdfImageIOException(ex.Message,ex);
 //            }
 //        }
 /// <summary>
 /// Method that adds a text element 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>
 public void addText(string newText, int X, int Y, predefinedFont fontType, int fontSize)
 {
     textElement objText = new textElement(newText, fontSize, fontType, X, Y);
     _persistentElements.Add(objText);
     objText = null;
 }
Ejemplo n.º 35
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>
 /// <returns>IEnumerable interface that cointains paragraphLine objects</returns>
 public static IEnumerable formatParagraph(string strText, int fontSize, predefinedFont fontType, int parWidth)
 {
     return(formatParagraph(strText, fontSize, fontType, parWidth, fontSize + 4, predefinedAlignment.csLeft));
 }
 /// <summary>
 /// Method that adds a paragraph to the page object
 /// </summary>
 /// <param name="newText">Interface IEnumerable that contains paragraphLine objects</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>
 public void addParagraph(IEnumerable newText, int x, int y, predefinedFont fontType, int fontSize)
 {
     try {
     paragraphElement objParagraph = new paragraphElement(newText, fontSize, fontType, x, y);
     _persistentElements.Add(objParagraph);
     objParagraph = null;
     } catch (pdfIncorrectParagraghException ex) {
         UnityEngine.Debug.Log ( ex );
         throw new pdfIncorrectParagraghException();
     }
 }