public virtual void ReplaceHeaderFooter(XmlDocument doc, XmlNamespaceManager xmlNsmgr, PaperType paperType, MandantLogoModel mandantLogoModel, OutputFormat outputFormat) { XmlNode docPageNode = doc.SelectSingleNode("//nm:Page", xmlNsmgr); XmlNode docReportNode = doc.SelectSingleNode("//nm:Report", xmlNsmgr); RemoveXmlNode(PageHeaderXPath, doc, docPageNode, xmlNsmgr); RemoveXmlNode(PageFooterXPath, doc, docPageNode, xmlNsmgr); RemoveXmlNode(EmbeddedImagesXPath, doc, docReportNode, xmlNsmgr); Stream templateRdlcXmlStream = reportResourceLocator.GetReportDefinitionStream(string.Format("{0}{1}_{2}.rdlc", HeaderFooterSubreportRdlcName, paperType, outputFormat.ToFileExtension())); var templateDoc = new XmlDocument(); templateDoc.Load(templateRdlcXmlStream); var templateDocHeader = templateDoc.SelectSingleNode(PageHeaderXPath, xmlNsmgr); PositionMandantLogo(templateDocHeader, xmlNsmgr, mandantLogoModel); docPageNode.InnerXml += templateDocHeader.OuterXml; docPageNode.InnerXml += templateDoc.SelectSingleNode(PageFooterXPath, xmlNsmgr).OuterXml; docReportNode.InnerXml += templateDoc.SelectSingleNode(EmbeddedImagesXPath, xmlNsmgr).OuterXml; //PositionMandantLogo(docPageNode, xmlNsmgr, mandantLogoModel); var reportParametersNode = doc.SelectSingleNode("//nm:ReportParameters", xmlNsmgr); reportParametersNode.InnerXml += "<ReportParameter Name=\"ReportTitle\"><DataType>String</DataType><Prompt>ReportParameter1</Prompt></ReportParameter>"; reportParametersNode.InnerXml += "<ReportParameter Name=\"FooterText\"><DataType>String</DataType><Nullable>true</Nullable><AllowBlank>true</AllowBlank><Prompt>ReportParameter1</Prompt></ReportParameter>"; reportParametersNode.InnerXml += "<ReportParameter Name=\"IsExcelOutput\"><DataType>Boolean</DataType><Prompt>ReportParameter1</Prompt></ReportParameter>"; }
private void PositionMandantLogo(XmlNode docPageNode, XmlNamespaceManager xmlNsmgr, MandantLogoModel mandantLogoModel) { var leftNode = docPageNode.SelectSingleNode("//nm:Image[@Name='HeaderMandantImage']/nm:Left", xmlNsmgr); var topNode = docPageNode.SelectSingleNode("//nm:Image[@Name='HeaderMandantImage']/nm:Top", xmlNsmgr); var widthNode = docPageNode.SelectSingleNode("//nm:Image[@Name='HeaderMandantImage']/nm:Width", xmlNsmgr); var heightNode = docPageNode.SelectSingleNode("//nm:Image[@Name='HeaderMandantImage']/nm:Height", xmlNsmgr); var width = decimal.Divide(mandantLogoModel.Width, mandantLogoModel.Height) * ParseValueWithMeasure(heightNode.InnerText); decimal shiftHorizontal = ParseValueWithMeasure(widthNode.InnerText) - width; if (shiftHorizontal < 0) { var height = decimal.Divide(mandantLogoModel.Height, mandantLogoModel.Width) * ParseValueWithMeasure(widthNode.InnerText); decimal shiftVertical = ParseValueWithMeasure(heightNode.InnerText) - height; heightNode.InnerText = ToRdlcCm(Math.Round(height, 2)); topNode.InnerText = ToRdlcCm(Math.Round(ParseValueWithMeasure(topNode.InnerText) + shiftVertical, 2)); } else { widthNode.InnerText = ToRdlcCm(Math.Round(width, 2)); leftNode.InnerText = ToRdlcCm(Math.Round(ParseValueWithMeasure(leftNode.InnerText) + shiftHorizontal, 2)); } }
public override void ReplaceHeaderFooter(XmlDocument doc, XmlNamespaceManager xmlNsmgr, PaperType paperType, MandantLogoModel mandantLogoModel, OutputFormat outputFormat) { XmlNode docPageNode = doc.SelectSingleNode("//nm:Page", xmlNsmgr); XmlNode docReportNode = doc.SelectSingleNode("//nm:Report", xmlNsmgr); RemoveXmlNode(PageHeaderXPath, doc, docPageNode, xmlNsmgr); RemoveXmlNode(PageFooterXPath, doc, docPageNode, xmlNsmgr); RemoveXmlNode(EmbeddedImagesXPath, doc, docReportNode, xmlNsmgr); var reportParametersNode = doc.SelectSingleNode("//nm:ReportParameters", xmlNsmgr); reportParametersNode.InnerXml += "<ReportParameter Name=\"ReportTitle\"><DataType>String</DataType><Prompt>ReportParameter1</Prompt></ReportParameter>"; reportParametersNode.InnerXml += "<ReportParameter Name=\"FooterText\"><DataType>String</DataType><Nullable>true</Nullable><AllowBlank>true</AllowBlank><Prompt>ReportParameter1</Prompt></ReportParameter>"; reportParametersNode.InnerXml += "<ReportParameter Name=\"IsExcelOutput\"><DataType>Boolean</DataType><Prompt>ReportParameter1</Prompt></ReportParameter>"; }