public void PrintText(Text text) { pdfStream.SaveState(); pdfStream.SetRGBColorFill(text.rgbColor.Red, text.rgbColor.Green, text.rgbColor.Blue); pdfStream.BeginText(); pdfStream.SetFont(defaultFont, text.FontSize); pdfStream.SetTextPos(text.X, (text.H - text.Y)); pdfStream.ShowText(text.Label); pdfStream.EndText(); pdfStream.RestoreState(); }
public void PutBand(Band band, int h) { foreach (var current in band.Elements) { if (current is Text) { var t1 = (Text)current; var t2 = new Text(t1.Label, t1.Align, t1.X, t1.Y) {FontSize = t1.FontSize, rgbColor = t1.rgbColor}; AddElement(t2, h); } else if (current is Expression) { var e1 = (Expression)current; var t2 = new Text(e1.Value.ToString(), TextAlignment.Left, e1.X, e1.Y) { FontSize = e1.FontSize, rgbColor = new RgbColor("#000000") }; AddElement(t2, h); } else if (current is Image) { AddElement(current, h); } else if (current is Rectangle) { var r1 = (Rectangle)current; var r2 = new Rectangle { x = r1.x, y = r1.y, height = r1.height, width = r1.width, bordercolor = r1.bordercolor, fillcolor = r1.fillcolor }; AddElement(r2, h); } else if (current is Bookmark) { AddElement(current, h); } } }
private static void ParseBand(XmlReader reader, Band band, Report report) { while (reader.Read()) { if (reader.Name.Equals("Band") && (reader.NodeType == XmlNodeType.EndElement)) break; switch (reader.NodeType) { case XmlNodeType.Element: int x; int y; int fontSize; int height; int width; switch (reader.Name) { case "StaticText": x = XmlConvert.ToInt16(reader.GetAttribute("x")); y = XmlConvert.ToInt16(reader.GetAttribute("y")); fontSize = XmlConvert.ToInt16(reader.GetAttribute("font-size")); var color = reader.GetAttribute("color"); var content = reader.ReadString(); var t = new Text(content, TextAlignment.Left, x, y) {FontSize = fontSize, rgbColor = new RgbColor(color)}; band.Elements.Add(t); break; case "Expression": x = XmlConvert.ToInt16(reader.GetAttribute("x")); y = XmlConvert.ToInt16(reader.GetAttribute("y")); fontSize = XmlConvert.ToInt16(reader.GetAttribute("font-size")); var strtype = reader.GetAttribute("type"); var e = new Expression(reader.ReadString()) {X = x, Y = y, FontSize = fontSize, Type = strtype}; band.Elements.Add(e); band.parent.Expressions.Add(e); break; case "Image": x = XmlConvert.ToInt16(reader.GetAttribute("x")); y = XmlConvert.ToInt16(reader.GetAttribute("y")); height = XmlConvert.ToInt16(reader.GetAttribute("height")); width = XmlConvert.ToInt16(reader.GetAttribute("width")); var url = reader.GetAttribute("href"); var i = (Image) report.ImageCollection[url]; var i2 = new Image(url, x, y) {width = width, height = height, ImageName = i.ImageName}; band.Elements.Add(i2); break; case "Rectangle": x = XmlConvert.ToInt16(reader.GetAttribute("x")); y = XmlConvert.ToInt16(reader.GetAttribute("y")); height = XmlConvert.ToInt16(reader.GetAttribute("height")); width = XmlConvert.ToInt16(reader.GetAttribute("width")); var bordercolor = reader.GetAttribute("bordercolor"); var fillcolor = reader.GetAttribute("fillcolor"); var r = new Rectangle { x = x, y = y, width = width, height = height, bordercolor = new RgbColor(bordercolor), fillcolor = new RgbColor(fillcolor) }; band.Elements.Add(r); break; case "Bookmark": var var = reader.GetAttribute("var"); var id = reader.GetAttribute("id"); var b = new Bookmark(var); band.Elements.Add(b); break; } break; } } }