当前位置: 首页>>代码示例>>C#>>正文


C# DocumentObjectModel.DocumentObject类代码示例

本文整理汇总了C#中MigraDoc.DocumentObjectModel.DocumentObject的典型用法代码示例。如果您正苦于以下问题:C# DocumentObject类的具体用法?C# DocumentObject怎么用?C# DocumentObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DocumentObject类属于MigraDoc.DocumentObjectModel命名空间,在下文中一共展示了DocumentObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NodeHandler

        public DocumentObject NodeHandler(HtmlNode node, DocumentObject parent, DocumentObject current = null)
        {
            var @class = node.Attributes["class"];

            if (!(parent is Section))
            {
                return parent;
            }

            var sec = (Section)parent;

            if (@class != null && @class.Value == "report")
            {
                var margins = node.Attributes["data-margin"];
                if (margins == null)
                {
                    sec.PageSetup.TopMargin = Unit.FromCentimeter(0.1);
                    sec.PageSetup.BottomMargin = Unit.FromCentimeter(0.1);
                    sec.PageSetup.LeftMargin = Unit.FromCentimeter(0.1);
                    sec.PageSetup.RightMargin = Unit.FromCentimeter(0.1);
                }
                else
                {
                    var marginValues = margins.Value.Split(' ');

                    sec.PageSetup.TopMargin = Unit.FromCentimeter(double.Parse(marginValues[0]));
                    sec.PageSetup.RightMargin = Unit.FromCentimeter(double.Parse(marginValues[1]));
                    sec.PageSetup.BottomMargin = Unit.FromCentimeter(double.Parse(marginValues[2]));
                    sec.PageSetup.LeftMargin = Unit.FromCentimeter(double.Parse(marginValues[3]));
                }
            }

            return parent;
        }
开发者ID:jgshumate1,项目名称:MigraDoc.Extensions,代码行数:34,代码来源:ReportHandler.cs

示例2: renderingHtmlImg

        protected override HtmlItem renderingHtmlImg(HtmlItem it, ref Paragraph par, HtmlItem parent, DocumentObject renderparent)
        {
            HtmlImg imagen = it as HtmlImg;
            MigraDoc.DocumentObjectModel.Shapes.Image img = null;
            MigraDoc.DocumentObjectModel.Shapes.TextFrame tf = null;
            if (imagen != null)
            {
                string route = AppDomain.CurrentDomain.BaseDirectory;
                string directorytem = Settings1.Default.routetem;
                string filename = RandomString(16, false) + "." + imagen.ImageType.ToString();
                string routecompleted = route + directorytem + "\\" + filename;
                imagen.Image.Save(routecompleted);

                MigraDoc.DocumentObjectModel.Tables.Cell cellparent = renderparent as MigraDoc.DocumentObjectModel.Tables.Cell;
                if (cellparent != null)
                {
                    tf = cellparent.AddTextFrame();
                    tf.WrapFormat.Style = MigraDoc.DocumentObjectModel.Shapes.WrapStyle.Through;
                }

                if (tf != null)
                    img = tf.AddImage(routecompleted);
                else
                    img = par.AddImage(routecompleted);

                RenderStyle.CreateRenderStyle(it, ref img).Render();
                listTempFiles.Add(routecompleted);
                imagen.SizeRenderItem = new RenderSizeItem() { Width = Convert.ToDecimal(img.Width), Height = Convert.ToDecimal(img.Height) };

            }

            return imagen;
        }
开发者ID:adrianillo,项目名称:HtmlToPdf,代码行数:33,代码来源:RenderHtmlImg.cs

示例3: ChartRenderer

 internal ChartRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
   : base(domObj, docRenderer)
 {
   this.chart = (Chart)domObj;
   this.isInline = DocumentRelations.HasParentOfType(this.chart, typeof(Paragraph)) ||
     RenderInParagraph();
 }
开发者ID:DavidS,项目名称:MigraDoc,代码行数:7,代码来源:ChartRenderer.cs

示例4: renderingHtmltr

        protected override HtmlItem renderingHtmltr(HtmlItem it, ref Paragraph par, HtmlItem parent, DocumentObject renderparent)
        {
            Htmltr tr = it as Htmltr;
            MigraDoc.DocumentObjectModel.Tables.Row rw = null;
            if (tr != null)
            {
                HtmlTable tb = parent as HtmlTable;
                if (tb != null)
                {
                    MigraDoc.DocumentObjectModel.Tables.Table tt = renderparent as MigraDoc.DocumentObjectModel.Tables.Table;
                    if (tt != null)
                    {
                        if (tt.Columns.Count > 0)
                            rw = tt.AddRow();

                        tr.SetTableParent(tb);
                    }

                }
                foreach (HtmlItem t in it.ListItem)
                {
                    FormattedText ff = new FormattedText();
                    RenderStyle.CreateRenderStyle(it, ref ff).Render();
                    HtmlItem itemrendered = renderingit(t, ref par, it, rw);
                }
            }
            return tr;
        }
开发者ID:adrianillo,项目名称:HtmlToPdf,代码行数:28,代码来源:RenderHtmltr.cs

示例5: GetParent

    /// <summary>
    /// Gets the direct parent of the given document object.
    /// </summary>
    /// <param name="documentObject">The document object the parent is searched for.</param>
    public static DocumentObject GetParent(DocumentObject documentObject)
    {
      if (documentObject == null)
        throw new ArgumentNullException("documentObject");

      return documentObject.Parent;
    }
开发者ID:GorelH,项目名称:PdfSharp,代码行数:11,代码来源:DocumentRelations.cs

示例6: Renderer

 internal Renderer(XGraphics gfx, RenderInfo renderInfo, FieldInfos fieldInfos)
 {
     this.documentObject = renderInfo.DocumentObject;
     this.gfx = gfx;
     this.renderInfo = renderInfo;
     this.fieldInfos = fieldInfos;
 }
开发者ID:dankennedy,项目名称:MigraDoc,代码行数:7,代码来源:Renderer.cs

示例7: AddFormattedText

 /// <summary>
 /// Add formatted text to the MigraDoc object.
 /// </summary>
 /// <param name="parentObject">The MigraDoc object to store the elements in.</param>
 /// <returns>The formatted text object.</returns>
 private static FormattedText AddFormattedText(DocumentObject parentObject)
 {
     FormattedText formattedText = parentObject as FormattedText;
     if (formattedText == null)
         return GetParagraph(parentObject).AddFormattedText();
     else
         return formattedText.AddFormattedText();
 }
开发者ID:hol353,项目名称:ApsimX,代码行数:13,代码来源:HtmlToMigraDoc.cs

示例8: HasParentOfType

    /// <summary>
    /// Determines whether the specified documentObject has a
    /// parent of the given type somewhere within the document hierarchy.
    /// </summary>
    /// <param name="documentObject">The document object to check.</param>
    /// <param name="type">The parent type to search for.</param>
    public static bool HasParentOfType(DocumentObject documentObject, Type type)
    {
      if (documentObject == null)
        throw new ArgumentNullException("documentObject");

      if (type == null)
        throw new ArgumentNullException("type");

      return GetParentOfType(documentObject, type) != null;
    }
开发者ID:GorelH,项目名称:PdfSharp,代码行数:16,代码来源:DocumentRelations.cs

示例9: ImageRenderer

        internal ImageRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
            : base(domObj, docRenderer)
        {
            this.image = domObj as Image;
              this.filePath = this.image.GetFilePath(this.docRenderer.WorkingDirectory);
              this.isInline = DocumentRelations.HasParentOfType(this.image, typeof(Paragraph)) ||
             RenderInParagraph();

              CalculateImageDimensions();
        }
开发者ID:dankennedy,项目名称:MigraDoc,代码行数:10,代码来源:ImageRenderer.cs

示例10: AddHyperlink

 private static DocumentObject AddHyperlink(DocumentObject section, HtmlNode node)
 {
     string href = node.GetAttributeValue("href", "");
     Hyperlink link;
     if (href.StartsWith("#"))
         link = GetParagraph(section).AddHyperlink(href.Substring(1), HyperlinkType.Bookmark);
     else
         link = GetParagraph(section).AddHyperlink(href, HyperlinkType.Web);
     return link;
 }
开发者ID:kiwiroy,项目名称:ApsimX,代码行数:10,代码来源:HtmlToMigraDoc.cs

示例11: RendererBase

        /// <summary>
        /// Initializes a new instance of the RendererBase class.
        /// </summary>
        internal RendererBase(DocumentObject domObj, RtfDocumentRenderer docRenderer)
        {
            if (enumTranslationTable == null)
            CreateEnumTranslationTable();

              this.docObject = domObj;
              this.docRenderer = docRenderer;
              if (docRenderer != null)
            this.rtfWriter = docRenderer.RtfWriter;
              this.useEffectiveValue = false;
        }
开发者ID:dankennedy,项目名称:MigraDoc,代码行数:14,代码来源:RendererBase.cs

示例12: GetParentOfType

        /// <summary>
        /// Gets a parent of the document object with the given type somewhere within the document hierarchy.
        /// Returns null if none exists.
        /// </summary>
        /// <param name="documentObject">The document object the parent is searched for.</param>
        /// <param name="type">The parent type to search for.</param>
        public static DocumentObject GetParentOfType(DocumentObject documentObject, Type type)
        {
            if (documentObject == null)
                throw new ArgumentNullException("documentObject");

            if (type == null)
                throw new ArgumentNullException("type");

            if (documentObject._parent != null)
            {
                if (documentObject._parent.GetType() == type)
                    return documentObject._parent;
                return GetParentOfType(documentObject._parent, type);
            }
            return null;
        }
开发者ID:Sl0vi,项目名称:MigraDoc,代码行数:22,代码来源:DocumentRelations.cs

示例13: NodeHandler

        public DocumentObject NodeHandler(HtmlNode node, ExCSS.Stylesheet sheet, DocumentObject parent, DocumentObject current = null)
        {
            if (!(parent is Section))
            {
                return parent;
            }

            var sec = (Section)parent;
            
            Unit margin;
            SetMargin(node, sheet, out margin, "margin-top");
            sec.PageSetup.TopMargin = margin;
            SetMargin(node, sheet, out margin, "margin-bottom");
            sec.PageSetup.BottomMargin = margin;
            SetMargin(node, sheet, out margin, "margin-left");
            sec.PageSetup.LeftMargin = margin;
            SetMargin(node, sheet, out margin, "margin-right");
            sec.PageSetup.LeftMargin = margin;
            return parent;
        }
开发者ID:jgshumate1,项目名称:MigraDoc.Extensions,代码行数:20,代码来源:ReportHandler.cs

示例14: renderingHtmlTable

        protected override HtmlItem renderingHtmlTable(HtmlItem it, ref Paragraph par, HtmlItem parent, DocumentObject renderparent)
        {
            HtmlTable tbl = it as HtmlTable;
            MigraDoc.DocumentObjectModel.Shapes.TextFrame tf = null;
            Paragraph partf = null;
            if (tbl != null)
            {
                MigraDoc.DocumentObjectModel.Tables.Table tt = null;
                MigraDoc.DocumentObjectModel.Tables.Cell cellparent = renderparent as MigraDoc.DocumentObjectModel.Tables.Cell;
                if (cellparent != null)
                {
                    tf = cellparent.AddTextFrame();
                    tt = tf.AddTable();
                    partf = tf.AddParagraph();

                }
                else
                    tt = par.Section.AddTable();

                tbl.SizeRenderItem.Width = 0;
                for (int i = 0; i < tbl.Cells; i++)
                {
                    MigraDoc.DocumentObjectModel.Tables.Column cc = tt.AddColumn();

                }

                foreach (HtmlItem t in it.ListItem)
                {
                    FormattedText ff = new FormattedText();
                    RenderStyle.CreateRenderStyle(it, ref ff).Render();
                    if (partf != null)
                        renderingit(t, ref partf, it, tt);
                    else
                        renderingit(t, ref par, it, tt);
                }
                RenderStyle.CreateRenderStyle(it, ref tt).Render();

            }
            return tbl;
        }
开发者ID:adrianillo,项目名称:HtmlToPdf,代码行数:40,代码来源:RenderHtmlTable.cs

示例15: ConvertHtmlNodes

        private void ConvertHtmlNodes(HtmlNodeCollection nodes, ExCSS.Stylesheet sheet, DocumentObject section, DocumentObject current = null)
        {
            foreach (var node in nodes)
            {
                Func<HtmlNode, ExCSS.Stylesheet, DocumentObject, DocumentObject> nodeHandler;

                Type t;
                if (_mapping.TryGetValue(node.Name, out t))
                {
                    var instance = (INodeHandler)Activator.CreateInstance(t);
                    var result = instance.NodeHandler(node, sheet, section);

                    if (node.HasChildNodes)
                    {
                        ConvertHtmlNodes(node.ChildNodes, sheet, section, result);
                    }
                }
                else
                {
                    if (nodeHandlers.TryGetValue(node.Name, out nodeHandler))
                    {
                        // pass the current container or section
                        var result = nodeHandler(node, sheet, current ?? section);

                        if (node.HasChildNodes)
                        {
                            ConvertHtmlNodes(node.ChildNodes, sheet, section, result);
                        }
                    }
                    else
                    {
                        if (node.HasChildNodes)
                        {
                            ConvertHtmlNodes(node.ChildNodes, sheet, section, current);
                        }
                    }
                }
            }
        }
开发者ID:jgshumate1,项目名称:MigraDoc.Extensions,代码行数:39,代码来源:HtmlConverter.cs


注:本文中的MigraDoc.DocumentObjectModel.DocumentObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。