コード例 #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;
            }
        }
コード例 #2
0
 /// <summary>
 /// Convert a AODL IContentCollection into an ArrayList of IElement iText objects.
 /// </summary>
 /// <param name="iContentCollection">The i content collection.</param>
 /// <returns>An ArrayList of iText IElement objects.</returns>
 public static ArrayList GetMixedPdfContent(IContentCollection iContentCollection)
 {
     try
     {
         ArrayList mixedPdfContent = new ArrayList();
         foreach (IContent content in iContentCollection)
         {
             if (content is AODL.Document.Content.Text.Paragraph)
             {
                 if (((AODL.Document.Content.Text.Paragraph)content).MixedContent != null &&
                     ((AODL.Document.Content.Text.Paragraph)content).MixedContent.Count > 0)
                 {
                     mixedPdfContent.Add(ParagraphConverter.Convert(
                                             content as AODL.Document.Content.Text.Paragraph));
                 }
                 else
                 {
                     mixedPdfContent.Add(iTextSharp.text.Chunk.NEWLINE);
                 }
             }
             else if (content is AODL.Document.Content.Text.Header)
             {
                 mixedPdfContent.Add(HeadingConverter.Convert(
                                         content as AODL.Document.Content.Text.Header));
             }
             else if (content is AODL.Document.Content.Tables.Table)
             {
                 TableConverter tc = new TableConverter();
                 mixedPdfContent.Add(tc.Convert(
                                         content as AODL.Document.Content.Tables.Table));
             }
             else if (content is AODL.Document.Content.Draw.Frame)
             {
                 DrawFrameConverter dfc = new DrawFrameConverter();
                 mixedPdfContent.Add(dfc.Convert(
                                         content as AODL.Document.Content.Draw.Frame));
             }
             else if (content is AODL.Document.Content.Draw.Graphic)
             {
                 ImageConverter ic = new ImageConverter();
                 mixedPdfContent.Add(ic.Convert(
                                         content as AODL.Document.Content.Draw.Graphic));
             }
         }
         return(mixedPdfContent);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
コード例 #3
0
 /// <summary>
 /// Convert a AODL IContentCollection into an ArrayList of IElement iText objects.
 /// </summary>
 /// <param name="iContentCollection">The i content collection.</param>
 /// <returns>An ArrayList of iText IElement objects.</returns>
 public static ArrayList GetMixedPdfContent(IContentCollection iContentCollection)
 {
     try
     {
         ArrayList mixedPdfContent = new ArrayList();
         foreach(IContent content in iContentCollection)
         {
             if(content is AODL.Document.Content.Text.Paragraph)
             {
                 if(((AODL.Document.Content.Text.Paragraph)content).MixedContent != null
                     && ((AODL.Document.Content.Text.Paragraph)content).MixedContent.Count > 0)
                         mixedPdfContent.Add(ParagraphConverter.Convert(
                             content as AODL.Document.Content.Text.Paragraph));
                 else
                     mixedPdfContent.Add(iTextSharp.text.Chunk.NEWLINE);
             }
             else if(content is AODL.Document.Content.Text.Header)
             {
                 mixedPdfContent.Add(HeadingConverter.Convert(
                     content as AODL.Document.Content.Text.Header));
             }
             else if(content is AODL.Document.Content.Tables.Table)
             {
                 TableConverter tc = new TableConverter();
                 mixedPdfContent.Add(tc.Convert(
                     content as AODL.Document.Content.Tables.Table));
             }
             else if(content is AODL.Document.Content.Draw.Frame)
             {
                 DrawFrameConverter dfc = new DrawFrameConverter();
                 mixedPdfContent.Add(dfc.Convert(
                     content as AODL.Document.Content.Draw.Frame));
             }
             else if(content is AODL.Document.Content.Draw.Graphic)
             {
                  ImageConverter ic = new ImageConverter();
                 mixedPdfContent.Add(ic.Convert(
                     content as AODL.Document.Content.Draw.Graphic));
             }
         }
         return mixedPdfContent;
     }
     catch(Exception ex)
     {
         throw;
     }
 }
コード例 #4
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;
            }
        }