/// <summary> /// Draws the document loop /// </summary> /// <param name="loopData"></param> protected void _drawLoop(List <Hashtable> loopData) { RowGroup rowGroup = PageDefinition.Loop; foreach (Hashtable data in loopData) { DrawRowGroup(rowGroup, data, DocumentGroup.Loop); } }
/// <summary> /// Draws the document header /// </summary> public void DrawHeader() { RowGroup rowGroup = PageDefinition.Header.RowGroup; foreach (Row row in rowGroup.Rows) { PdfDrawer.NextRow(row.Height, DocumentGroup.Header); DrawRow(row.DrawElements, headerData); } }
/// <summary> /// Draw rowGroup to the Pdf, when goto nextPage, repeat the header! /// 201306060 :: mellorasinxelas to write absolute groups /// </summary> /// <param name="rowGroup"></param> /// <param name="data"></param> /// <param name="dGroup"></param> public void DrawRowGroup(RowGroup rowGroup, System.Collections.IDictionary data, DocumentGroup dGroup) { bool absolute = false; if (rowGroup is Moon.PDFTemplate.FooterGroup) { absolute = ((Moon.PDFTemplate.FooterGroup)rowGroup).Absolute; } float oldY = -1; bool ignoreAddRow = false; if (absolute) { oldY = PdfDrawer.CurrentY(); PdfDrawer.SetY(PageDefinition.Margin_bottom + ((rowGroup.Y != -1.0F) ? rowGroup.Y : rowGroup.Height)); //20130610 :: Use sY if is stored, otherwise uses Height. ignoreAddRow = true; //position has been stored. } foreach (Row row in rowGroup.Rows) { if (!absolute) { if (PdfDrawer.isNoMoreY(row.Height, dGroup)) { NextPage(); DrawHeader(); } } if (ignoreAddRow) { ignoreAddRow = false; } else { PdfDrawer.NextRow(row.Height, dGroup); } DrawRow(row.DrawElements, data); } //returns to old Y value. if (absolute) { PdfDrawer.SetY(oldY); } }
/// <summary> /// draw row and table items inside body. /// table items are treated as tables /// </summary> public void DrawBody(Hashtable data, IPDFDraw drawer) { if (bodyItems == null) return; XmlAttributeCollection font = pdfTemplate.DefaultFontAttrs; if (bodyNode.FirstChild.Name == "font") { font = bodyNode.FirstChild.Attributes; } foreach (XmlNode itemNode in bodyItems) { if (!IsNodeVisible(itemNode, data)) continue; if (itemNode.Name == "row") { RowGroup rowGroup = new RowGroup { Y = Helper.GetFloatAttributeValue("y", bodyNode.Attributes, -1) }; rowGroup.AddRow(pdfTemplate._buildRow(itemNode, font)); pdfTemplate.DrawRowGroup(rowGroup, data, DocumentGroup.Body); } else if (itemNode.Name == "table") { var tableGenerator = new TableGenerator(pdfTemplate, itemNode); if (itemNode.Attributes == null) continue; var keyAttribute = itemNode.Attributes["var"]; if (keyAttribute == null || !data.ContainsKey(keyAttribute.Value)) continue; var tableParameters = data[keyAttribute.Value]; if (!(tableParameters is TableData)) throw new Exception("table parameter must be of type TableData"); tableGenerator.DrawTable((TableData) (tableParameters), drawer); } } }
//jaimelopez :: 20130606 /// <summary> /// Draws the document footer. /// </summary> protected void _drawFooter() { RowGroup rowGroup = PageDefinition.Footer.RowGroup; // if(rowGroup is FooterGroup){ // if( ((FooterGroup)rowGroup).Absolute) return; //print int NextPage operation. // } if (!(rowGroup is FooterGroup) || !((FooterGroup)rowGroup).Absolute) { if (rowGroup.Y != -1) { if (PdfDrawer.CurrentY() < rowGroup.Y) { NextPage(); DrawHeader(); } PdfDrawer.SetY(rowGroup.Y); } } DrawRowGroup(rowGroup, footerData, DocumentGroup.Footer); }
/// <summary> /// </summary> /// /// <param name="node">node of xml header, body, footer, loop</param> /// <param name="footer">True if its a footer page element</param> /// <returns></returns> public RowGroup _buildRowGroup(XmlNode node, bool footer) { //20130606 :: jaimelopez RowGroup rowGroup = null; if (footer) { rowGroup = new FooterGroup(XmlHelper.GetAttributeBoolean(FooterGroup.AbsoluteAttribute, node.Attributes, false)); } else { rowGroup = new RowGroup(); } //-- rowGroup.Y = XmlHelper.GetFloatAttributeValue("y", node.Attributes, -1); XmlAttributeCollection _font = DefaultFontAttrs; if (node.FirstChild.Name == "font") { _font = node.FirstChild.Attributes; } XmlNodeList rowNodes = node.SelectNodes(".//row"); foreach (XmlNode rowNode in rowNodes) { if (rowNode.Name == "row") { rowGroup.AddRow(_buildRow(rowNode, _font)); } } return(rowGroup); }
/// <summary> /// Draw rowGroup to the Pdf, when goto nextPage, repeat the header! /// 201306060 :: mellorasinxelas to write absolute groups /// </summary> /// <param name="rowGroup"></param> /// <param name="data"></param> /// <param name="dGroup"></param> public void DrawRowGroup(RowGroup rowGroup, System.Collections.IDictionary data, DocumentGroup dGroup) { bool absolute = false; if (rowGroup is Moon.PDFTemplate.FooterGroup) { absolute = ((Moon.PDFTemplate.FooterGroup)rowGroup).Absolute; } float oldY = -1; bool ignoreAddRow = false; if (absolute) { oldY = PdfDrawer.CurrentY(); PdfDrawer.SetY(PageDefinition.Margin_bottom + ((rowGroup.Y != -1.0F) ? rowGroup.Y : rowGroup.Height));//20130610 :: Use sY if is stored, otherwise uses Height. ignoreAddRow = true; //position has been stored. } foreach (Row row in rowGroup.Rows) { if (!absolute) { if (PdfDrawer.isNoMoreY(row.Height, dGroup)) { NextPage(); DrawHeader(); } } if (ignoreAddRow) { ignoreAddRow = false; } else { PdfDrawer.NextRow(row.Height, dGroup); } DrawRow(row.DrawElements, data); } //returns to old Y value. if (absolute) { PdfDrawer.SetY(oldY); } }
/// <summary> /// </summary> /// /// <param name="node">node of xml header, body, footer, loop</param> /// <param name="footer">True if its a footer page element</param> /// <returns></returns> private RowGroup _buildRowGroup(XmlNode node, bool footer) { //20130606 :: jaimelopez RowGroup rowGroup = null; if (footer) { rowGroup = new FooterGroup(PDFDraw.Helper.GetAttributeBoolean(FooterGroup.AbsoluteAttribute, node.Attributes, false)); } else { rowGroup = new RowGroup(); } //-- rowGroup.Y = PDFDraw.Helper.GetFloatAttributeValue("y", node.Attributes, -1); XmlAttributeCollection _font = DefaultFontAttrs; if (node.FirstChild.Name == "font") { _font = node.FirstChild.Attributes; } XmlNodeList rowNodes = node.SelectNodes(".//row"); foreach (XmlNode rowNode in rowNodes) { if(rowNode.Name == "row") rowGroup.AddRow(_buildRow(rowNode, _font)); } return rowGroup; }