Exemplo n.º 1
0
        protected override void DoDataBind(PDFDataContext context, bool includeChildren)
        {
            base.DoDataBind(context, includeChildren);


            if (null != _literal)
            {
                this.Contents.Remove(_literal);
            }

            object data = GetRequiredData(context);

            if (null == data)
            {
                return;
            }

            _literal = new Components.TextLiteral();

            var format = Newtonsoft.Json.Formatting.Indented;

            _literal.Text = Newtonsoft.Json.JsonConvert.SerializeObject(data, format);



            this.Contents.Add(_literal);
        }
Exemplo n.º 2
0
        protected override void DoDataBind(PDFDataContext context, bool includeChildren)
        {
            base.DoDataBind(context, includeChildren);


            if (null != _literal)
            {
                this.Contents.Remove(_literal);
            }

            object data = GetRequiredData(context);

            if (null == data)
            {
                return;
            }

            _literal = new Components.TextLiteral();


            if (data is System.Xml.XPath.XPathNavigator)
            {
                _literal.Text = ((System.Xml.XPath.XPathNavigator)data).OuterXml;
            }

            else if (data is System.Xml.XPath.XPathNodeIterator)
            {
                System.Xml.XPath.XPathNodeIterator itter = (System.Xml.XPath.XPathNodeIterator)data;

                //Clone it so we do not affect anything else
                itter = itter.Clone();

                StringBuilder sb = new StringBuilder();
                while (itter.MoveNext())
                {
                    sb.AppendLine(itter.Current.OuterXml);
                }
                _literal.Text = sb.ToString();
            }

            this.Contents.Add(_literal);
        }