/// <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; } }
/// <summary> /// Converts the specified formated text. /// </summary> /// <param name="formatedText">The formated text.</param> /// <returns>The chunck object representing this formated text.</returns> public static iTextSharp.text.Phrase Convert(AODL.Document.Content.Text.FormatedText formatedText) { try { iTextSharp.text.Font font; if ((TextStyle)formatedText.Style != null && ((TextStyle)formatedText.Style).TextProperties != null) { font = TextPropertyConverter.GetFont( ((TextStyle)formatedText.Style).TextProperties); } else { font = DefaultDocumentStyles.Instance().DefaultTextFont; } iTextSharp.text.Phrase phrase = new iTextSharp.text.Phrase("", font); // default ctor protected - why ?? phrase.AddRange(FormatedTextConverter.GetTextContents(formatedText.TextContent, font)); return(phrase); } catch (Exception) { throw; } }
/// <summary> /// Converts the specified heading. /// </summary> /// <param name="heading">The heading.</param> /// <returns>A PDF paragraph representing the ODF heading</returns> public static iTextSharp.text.Paragraph Convert(Header heading) { try { iTextSharp.text.Font font = DefaultDocumentStyles.Instance().DefaultTextFont; IStyle style = heading.Document.CommonStyles.GetStyleByName(heading.StyleName); if (style != null && style is ParagraphStyle) { if ((ParagraphStyle)style != null) { if (((ParagraphStyle)style).ParentStyle != null) { IStyle parentStyle = heading.Document.CommonStyles.GetStyleByName( ((ParagraphStyle)style).ParentStyle); if (parentStyle != null && parentStyle is ParagraphStyle && ((ParagraphStyle)parentStyle).TextProperties != null && ((ParagraphStyle)style).TextProperties != null) { // get parent style first font = TextPropertyConverter.GetFont(((ParagraphStyle)parentStyle).TextProperties); // now use the orignal style as multiplier font = TextPropertyConverter.FontMultiplier(((ParagraphStyle)style).TextProperties, font); } else { font = TextPropertyConverter.GetFont(((ParagraphStyle)style).TextProperties); } } else { font = TextPropertyConverter.GetFont(((ParagraphStyle)style).TextProperties); } } } iTextSharp.text.Paragraph paragraph = new iTextSharp.text.Paragraph("", font); // default ctor protected - why ?? paragraph.AddRange(FormatedTextConverter.GetTextContents(heading.TextContent, font)); return(paragraph); } catch (Exception ex) { throw; } }
/// <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; } }