Exemple #1
0
        private void InsertText(int pageNumber, Alignment alignment, string text, float x, float y, BaseFont font, int size)
        {
            bool singleLine = true;

            if (text.Contains(Environment.NewLine))
            {
                AddMultipleLinesOrder(pageNumber, alignment, text, x, y, font, size);
                singleLine = false;
            }

            if (singleLine)
            {
                var nuevoTexto = new TextAddition(alignment, pageNumber, text, x, y, font, size);
                textToAddList.Add(nuevoTexto);
            }
        }
Exemple #2
0
        /// <summary>
        /// This methods writes some text on the final file
        /// </summary>
        /// <param name="pageNumber">Number of the page in which it will be written (based at 1)</param>
        /// <param name="alignment">Alignment for the text, specified through an enum the class contains</param>
        /// <param name="text">String of text to be written. Can contain <c cref="Environment.NewLine">Environment.NewLine</c> and will make a new line</param>
        /// <param name="x">X coordinate for the reference point for the text in the page</param>
        /// <param name="y">Y coordinate for the reference point for the text in the page</param>
        /// <param name="font">String with the name of the font to be used. Will be searched for in a built in dictionary</param>
        /// <param name="size">Size of the font</param>
        public void InsertText(int pageNumber, Alignment alignment, string text, float x, float y, string font, int size)
        {
            bool singleLine = true;

            if (text.Contains(Environment.NewLine))
            {
                AddMultipleLinesOrder(pageNumber, alignment, text, x, y, font, size);
                singleLine = false;
            }

            if (singleLine)
            {
                try {
                    var fontAux    = FontList.ElementAt(fonts[font]);
                    var nuevoTexto = new TextAddition(alignment, pageNumber, text, x, y, fontAux, size);
                    textToAddList.Add(nuevoTexto);
                }
                catch {
                    throw new Exception("Font wasn't found in the fonts dictionary");
                }
            }
        }