本文整理汇总了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;
}
示例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;
}
示例3: ChartRenderer
internal ChartRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
: base(domObj, docRenderer)
{
this.chart = (Chart)domObj;
this.isInline = DocumentRelations.HasParentOfType(this.chart, typeof(Paragraph)) ||
RenderInParagraph();
}
示例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;
}
示例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;
}
示例6: Renderer
internal Renderer(XGraphics gfx, RenderInfo renderInfo, FieldInfos fieldInfos)
{
this.documentObject = renderInfo.DocumentObject;
this.gfx = gfx;
this.renderInfo = renderInfo;
this.fieldInfos = fieldInfos;
}
示例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();
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
}