private void AddSegmentText(SvgDocument document, int index, ComplexLine line,Segment segment, PointF targetPoint, PointF referencePoint)
        {
            //Get midpoint of segment
            PointF location = new PointF(targetPoint.X + ((referencePoint.X - targetPoint.X) / 2), targetPoint.Y + ((referencePoint.Y - targetPoint.Y) / 2));

            if (segment.Label.Text.Trim() == "") return;

            Style style = new Style();

            //Set up text object
            location = OffsetPoint(location, segment.Label.Offset);
            //location = OffsetPoint(location, line.Rectangle.Location);

            Double rotation = Geometry.DegreesFromRadians(Geometry.GetAngle(targetPoint.X, targetPoint.Y, referencePoint.X, referencePoint.Y));

            Text text = new Text();
            text.Label = segment.Label;
            text.LayoutRectangle = new RectangleF(location, new SizeF());

            //Get style
            string classId = null;
            classId = document.AddClass(text.GetStyle());

            //Create fragment and add to document
            XmlDocumentFragment frag = null;
            XmlNode newElementNode = null;

            frag = document.CreateDocumentFragment();
            frag.InnerXml = text.ExtractText(0, 0, line.Key + index.ToString() + "Text", "rotate(" + rotation.ToString() + "," + location.X.ToString() + "," + location.Y.ToString() + ")");
            //frag.InnerXml = text.ExtractText(0, 0, line.Key + index.ToString() + "Text");
            frag.FirstChild.Attributes.GetNamedItem("class").InnerText = classId;
            newElementNode = document.ContainerNode.AppendChild(frag);
        }
        private void AddLinkText(SvgDocument document, Link link)
        {
            if (link.Label.Text.Trim() == "") return;

            Style style = new Style();

            //Set up text object
            PointF location = link.GetLabelLocation();
            location = OffsetPoint(location, link.Label.Offset);
            location = OffsetPoint(location, link.Rectangle.Location);

            Text text = new Text();
            text.Label = link.Label;
            text.LayoutRectangle = new RectangleF(location, new SizeF());

            //Get style
            string classId = null;
            classId = document.AddClass(text.GetStyle());

            //Create fragment and add to document
            XmlDocumentFragment frag = null;
            XmlNode newElementNode = null;

            frag = document.CreateDocumentFragment();
            frag.InnerXml = text.ExtractText(0, 0, link.Key + "Text");
            frag.FirstChild.Attributes.GetNamedItem("class").InnerText = classId;
            newElementNode = document.ContainerNode.AppendChild(frag);
        }
		protected virtual void WriteHeading(SvgDocument document, Table table)
		{
			//Add heading
			mDefinition.Path = new GraphicsPath();
			mDefinition.Path.AddRectangle(new RectangleF(0,0,table.Width, table.HeadingHeight));

			//Add the definition
			string defId = document.AddDefinition(mDefinition.ExtractRectangle());
			
			//Add the class
			string gradient = Style.ExtractLinearGradient(LinearGradientMode.Horizontal, table.GradientColor, table.BackColor);
			string classId = document.AddClass("fill:url(#none)", gradient);
			
			document.AddUse("Heading", defId, classId, "", 0 , 0);

			//Add the rest of the background
			mDefinition.Path = new GraphicsPath();
			mDefinition.Path.AddRectangle(new RectangleF(0, 0, table.Width, table.Height - table.HeadingHeight));

			//Add the definition
			defId = document.AddDefinition(mDefinition.ExtractRectangle());
			classId = document.AddClass("fill:" + Style.GetCompatibleColor(table.BackColor));

			document.AddUse("Fill", defId, classId, "", 0 , table.HeadingHeight);

			Style style = new Style();
			Font font = null;

			//Add Heading text
			if (table.Heading.Trim() != "")
			{
				//Add clipping to style if required
				style.ClipPathId = ClipId;

				//Set up text object
				Text text = new Text();

				//Get style
				font = Component.Instance.GetFont(table.FontName,table.FontSize,FontStyle.Bold);
				classId = document.AddClass(text.GetStyle(font, table.Forecolor, ClipId), "");

				//Create fragment and add to document
				XmlDocumentFragment frag = null;
				XmlNode newElementNode = null;

				frag = document.CreateDocumentFragment();
				frag.InnerXml = text.ExtractText(table.Heading, font, 8, 5, table.Key +"Heading");
				frag.FirstChild.Attributes.GetNamedItem("class").InnerText = classId;
				newElementNode = document.ContainerNode.AppendChild(frag);
			}

			//Add Heading text
			if (table.SubHeading.Trim() != "")
			{
				style = new Style();

				//Add clipping to style if required
				style.ClipPathId = ClipId;

				//Set up text object
				Text text = new Text();

				//Get style
				font = Component.Instance.GetFont(table.FontName,table.FontSize-1,FontStyle.Regular);
				classId = document.AddClass(text.GetStyle(font, table.Forecolor, ClipId), "");

				//Create fragment and add to document
				XmlDocumentFragment frag = null;
				XmlNode newElementNode = null;

				frag = document.CreateDocumentFragment();
				frag.InnerXml = text.ExtractText(table.SubHeading, font, 8, 20, table.Key +"Subheading");
				frag.FirstChild.Attributes.GetNamedItem("class").InnerText = classId;
				newElementNode = document.ContainerNode.AppendChild(frag);
			}
		}
		protected virtual void WriteTableRow(SvgDocument document, Table table, TableRow row, ref int id, ref float height)
		{
			//Add background
			mDefinition.Path = new GraphicsPath();
			mDefinition.Path.AddRectangle(new RectangleF(0, 0, row.Indent, table.RowHeight));

			//Add the definition
			string defId = document.AddDefinition(mDefinition.ExtractRectangle());
			
			StringBuilder builder = new StringBuilder();
			builder.Append("fill:");
			builder.Append(Style.GetCompatibleColor(row.Backcolor));
			builder.Append(";fill-opacity:0.5;");

			//Add the class
			string classId = document.AddClass(builder.ToString());
			string key = "Row" + id.ToString();
			
			document.AddUse(key, defId, classId, "", 0, height);

			//Add the text
			Style style = new Style();
			Font font = null;

			//Add row text
			if (row.Text.Trim() != "")
			{
				//Get a new clip path
				mDefinition.Path = new GraphicsPath();
				mDefinition.Path.AddRectangle(new RectangleF(0, 0, table.Width - row.Indent, table.RowHeight));

				//Add the definition
				defId = document.AddDefinition(mDefinition.ExtractRectangle());
				string clipId = document.AddClipPath(defId, row.Indent, height);
				
				//Add clipping to style if required
				style.ClipPathId = clipId;

				StringFormat format = new StringFormat();
				format.LineAlignment = StringAlignment.Center;
				format.FormatFlags = StringFormatFlags.NoWrap;

				//Set up text object
				Text text = new Text();
				text.Format = format;	
				text.LayoutRectangle = new RectangleF(0, 0, table.Width - 20 - table.Indent - row.Indent, table.RowHeight);

				//Get style
				font = Component.Instance.GetFont(table.FontName, table.FontSize, table.FontStyle);
				classId = document.AddClass(text.GetStyle(font, table.Forecolor, clipId), "");

				//Create fragment and add to document
				XmlDocumentFragment frag = null;
				XmlNode newElementNode = null;

				frag = document.CreateDocumentFragment();
				frag.InnerXml = text.ExtractText(row.Text, font, row.Indent, height, key + "Text");
				frag.FirstChild.Attributes.GetNamedItem("class").InnerText = classId;
				newElementNode = document.ContainerNode.AppendChild(frag);
			}

			id++;
			height += table.RowHeight;
		}
		private void AddShapeText(SvgDocument document, SolidElement solid, string strClipId)
		{
			if (solid.Label.Text.Trim() == "") return;

			Style style = new Style();

			//Add clipping to style if required
			style.ClipPathId = strClipId;

			//Set up text object
			Text text = new Text();
			text.Label = solid.Label;
			text.LayoutRectangle = solid.InternalRectangle;

			//Get style
			string classId = null;
			classId = document.AddClass(text.GetStyle(strClipId), "");

			//Create fragment and add to document
			XmlDocumentFragment frag = null;
			XmlNode newElementNode = null;

			frag = document.CreateDocumentFragment();
			frag.InnerXml = text.ExtractText(0, 0, solid.Key +"Text");
			frag.FirstChild.Attributes.GetNamedItem("class").InnerText = classId;
			newElementNode = document.ContainerNode.AppendChild(frag);
		}