ConvertTabs() public static method

Converts the tabs.
public static ConvertTabs ( AODL tabStop, iTextSharp font ) : iTextSharp.text.Phrase
tabStop AODL The tab stop.
font iTextSharp
return iTextSharp.text.Phrase
Example #1
0
 /// <summary>
 /// Gets the text contents.
 /// </summary>
 /// <param name="textCollection">The text collection.</param>
 /// <returns>The content. ArrayList of chunks and phrases.</returns>
 public static ICollection GetTextContents(ITextCollection textCollection, iTextSharp.text.Font font)
 {
     try
     {
         ArrayList contents = new ArrayList();
         foreach (object obj in textCollection)
         {
             if (obj is AODL.Document.Content.Text.FormatedText)
             {
                 contents.Add(FormatedTextConverter.Convert(
                                  obj as AODL.Document.Content.Text.FormatedText));
             }
             else if (obj is AODL.Document.Content.Text.SimpleText)
             {
                 contents.Add(SimpleTextConverter.Convert(
                                  obj as AODL.Document.Content.Text.SimpleText, font));
             }
             else if (obj is AODL.Document.Content.Text.TextControl.TabStop)
             {
                 contents.Add(SimpleTextConverter.ConvertTabs(
                                  obj as AODL.Document.Content.Text.TextControl.TabStop, font));
             }
             else if (obj is AODL.Document.Content.Text.TextControl.WhiteSpace)
             {
                 contents.Add(SimpleTextConverter.ConvertWhiteSpaces(
                                  obj as AODL.Document.Content.Text.TextControl.WhiteSpace, font));
             }
         }
         return(contents);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Example #2
0
        /// <summary>
        /// Converts the specified paragraph.
        /// </summary>
        /// <param name="paragraph">The paragraph.</param>
        /// <returns>The PDF paragraph.</returns>
        public static iTextSharp.text.Paragraph Convert(AODL.Document.Content.Text.Paragraph paragraph)
        {
            try
            {
                iTextSharp.text.Font font;
                if ((ParagraphStyle)paragraph.Style != null &&
                    ((ParagraphStyle)paragraph.Style).TextProperties != null &&
                    ((ParagraphStyle)paragraph.Style).TextProperties.FontName != null)
                {
                    font = TextPropertyConverter.GetFont(
                        ((ParagraphStyle)paragraph.Style).TextProperties);
                }
                else
                {
                    font = DefaultDocumentStyles.Instance().DefaultTextFont;
                }

                ParagraphExt paragraphPDF = new ParagraphExt("", font);
                foreach (object obj in paragraph.MixedContent)
                {
                    if (obj is AODL.Document.Content.Text.FormatedText)
                    {
                        paragraphPDF.Add(FormatedTextConverter.Convert(
                                             obj as AODL.Document.Content.Text.FormatedText));
                    }
                    if (obj is AODL.Document.Content.Text.SimpleText)
                    {
                        paragraphPDF.Add(SimpleTextConverter.Convert(
                                             obj as AODL.Document.Content.Text.SimpleText, font));
                    }
                    else if (obj is AODL.Document.Content.Text.TextControl.TabStop)
                    {
                        paragraphPDF.Add(SimpleTextConverter.ConvertTabs(
                                             obj as AODL.Document.Content.Text.TextControl.TabStop, font));
                    }
                    else if (obj is AODL.Document.Content.Text.TextControl.WhiteSpace)
                    {
                        paragraphPDF.Add(SimpleTextConverter.ConvertWhiteSpaces(
                                             obj as AODL.Document.Content.Text.TextControl.WhiteSpace, font));
                    }
                    else if (obj is AODL.Document.Content.Draw.Frame)
                    {
                        DrawFrameConverter dfc = new DrawFrameConverter();
                        paragraphPDF.Add(dfc.Convert(
                                             obj as AODL.Document.Content.Draw.Frame));
                    }
                    else if (obj is AODL.Document.Content.Draw.Graphic)
                    {
                        ImageConverter ic = new ImageConverter();
                        paragraphPDF.Add(ic.Convert(
                                             obj as AODL.Document.Content.Draw.Graphic));
                    }
                }
                paragraphPDF = ParagraphConverter.ConvertParagraphStyles(paragraph, paragraphPDF);
                // add new line
                paragraphPDF.Add(iTextSharp.text.Chunk.NEWLINE);
                return(paragraphPDF);
            }
            catch (Exception)
            {
                throw;
            }
        }