ConvertParagraphStyles() public static method

Converts the paragraph styles.
public static ConvertParagraphStyles ( AODL paragraph, ParagraphExt paragraphPDF ) : ParagraphExt
paragraph AODL The paragraph.
paragraphPDF AODL.ExternalExporter.PDF.Document.iTextExt.ParagraphExt The paragraph PDF.
return AODL.ExternalExporter.PDF.Document.iTextExt.ParagraphExt
Exemplo n.º 1
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;
            }
        }