public XDocument ToXDocument(FoRenderOptions options) { return(new XDocument( new XDeclaration("1.0", "utf-8", null), ToXElement(options) )); }
public override XElement ToXElement(FoRenderOptions options) { XElement element = new XElement(FoUtils.Namespaces.Fo + "root"); RenderAttributes(element, options); RenderChildren(element, options); return(element); }
protected override void RenderAttributes(XElement element, FoRenderOptions options) { element.Add(new XAttribute(XNamespace.Xmlns + "fo", FoUtils.Namespaces.Fo)); if (Properties != null) { element.Add(new XAttribute(XNamespace.Xmlns + "ibex", FoUtils.Namespaces.Ibex)); } }
public override XElement ToXElement(FoRenderOptions options) { XElement xBlockContainer = Fo("block-container"); RenderAttributes(xBlockContainer, options); RenderChildren(xBlockContainer, options); return(xBlockContainer); }
public override XElement ToXElement(FoRenderOptions options) { XElement xBlock = Fo("basic-link"); RenderAttributes(xBlock, options); RenderChildren(xBlock, options); return(xBlock); }
public override XElement ToXElement(FoRenderOptions options) { XElement element = Fo("leader"); RenderAttributes(element, options); RenderChildren(element, options); return(element); }
public XmlDocument ToXmlDocument(FoRenderOptions options) { XmlDocument xmlDocument = new XmlDocument(); using (XmlReader xmlReader = ToXDocument(options).CreateReader()) { xmlDocument.Load(xmlReader); } return(xmlDocument); }
/// <summary> /// Save the <strong>XSL-FO</strong> document to a new stream, and returns that stream. /// </summary> /// <param name="options">The options.</param> /// <returns>An instance of <see cref="MemoryStream"/> representing the <strong>XSL-FO</strong> document.</returns> public MemoryStream GetStream(FoRenderOptions options) { // Initialize a new memory stream MemoryStream ms = new MemoryStream(); // Save the XSL-FO document to the stream Save(ms, options); // Return the stream. return(ms); }
protected override void RenderAttributes(XElement element, FoRenderOptions options) { base.RenderAttributes(element, options); if (InternalDestination.HasValue()) { element.Add(new XAttribute("internal-destination", InternalDestination)); } if (ExternalDestination.HasValue()) { element.Add(new XAttribute("external-destination", ExternalDestination)); } }
protected override void RenderChildren(XElement element, FoRenderOptions options) { base.RenderChildren(element, options); if (Properties != null) { element.Add(Properties.ToXElement(options)); } element.Add(LayoutMasterSet.ToXElement(options)); foreach (FoPageSequence pageSequence in PageSequences) { element.Add(pageSequence.ToXElement(options)); } }
public void Save(Stream stream, FoRenderOptions options) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } // Convert the document to an instance of "XDocument" XDocument document = ToXDocument(options); // Write the XML to "stream" document.Save(stream, options?.SaveOptions ?? SaveOptions.None); }
protected override void RenderChildren(XElement element, FoRenderOptions options) { foreach (FoNode node in Children) { switch (node) { case FoElement child: element.Add(child.ToXElement(options)); break; case FoText text when options == null || options.UseCData: element.Add(new XCData(text.Value ?? string.Empty)); break; case FoText text: element.Add(text.Value ?? string.Empty); break; } } }
protected override void RenderAttributes(XElement element, FoRenderOptions options) { base.RenderAttributes(element, options); if (LeaderPattern != FoLeaderPattern.Unspecified) { element.Add(new XAttribute("leader-pattern", ToKebabCase(LeaderPattern))); } if (LeaderLength.HasValue()) { element.Add(new XAttribute("leader-length", LeaderLength)); } if (Thickness.HasValue()) { element.Add(new XAttribute("rule-thickness", Thickness)); } if (Color.HasValue()) { element.Add(new XAttribute("color", Color)); } }
/// <summary> /// Renders the children of the element. /// </summary> /// <param name="element">The element to be rendered.</param> /// <param name="options">The options for rendering the element.</param> protected virtual void RenderChildren(XElement element, FoRenderOptions options) { }
/// <summary> /// Returns a string representation of the element using the specified formatting <paramref name="options"/>. /// </summary> /// <param name="options">The options for rendering the element.</param> /// <returns>The string representing the element.</returns> public string ToString(FoRenderOptions options) { return(ToXElement(options).ToString(options?.SaveOptions ?? SaveOptions.None)); }
/// <summary> /// Returns an <see cref="XElement"/> representation of the element using the specified formatting <paramref name="options"/>. /// </summary> /// <param name="options">The options for rendering the element.</param> /// <returns>The <see cref="XElement"/> representing the element.</returns> public abstract XElement ToXElement(FoRenderOptions options);
/// <summary> /// Renders the attributes of the element. /// </summary> /// <param name="element">The element to be rendered.</param> /// <param name="options">The options for rendering the element.</param> protected virtual void RenderAttributes(XElement element, FoRenderOptions options) { }
protected override void RenderAttributes(XElement element, FoRenderOptions options) { base.RenderAttributes(element, options); if (DisplayAlign != FoDisplayAlign.Inherit) { element.Add(new XAttribute("display-align", ToKebabCase(DisplayAlign))); } if (!string.IsNullOrEmpty(FontFamily)) { element.Add(new XAttribute("font-family", FontFamily)); } if (!string.IsNullOrEmpty(FontSize)) { element.Add(new XAttribute("font-size", FontSize)); } if (FontWeight != FoFontWeight.Inherit) { element.Add(new XAttribute("font-weight", ToKebabCase(FontWeight))); } if (FontStyle != FoFontStyle.Inherit) { element.Add(new XAttribute("font-style", ToKebabCase(FontStyle))); } if (TextAlign != FoTextAlign.Inherit) { element.Add(new XAttribute("text-align", ToKebabCase(TextAlign))); } if (TextDecoration != FoTextDecoration.Inherit) { element.Add(new XAttribute("text-decoration", ToKebabCase(TextDecoration))); } if (!string.IsNullOrEmpty(Color)) { element.Add(new XAttribute("color", Color)); } if (!string.IsNullOrEmpty(PageBreakBefore)) { element.Add(new XAttribute("page-break-before", PageBreakBefore)); } if (!string.IsNullOrEmpty(Background)) { element.Add(new XAttribute("background", Background)); } if (!string.IsNullOrEmpty(BackgroundImage)) { element.Add(new XAttribute("background-image", BackgroundImage)); } if (!string.IsNullOrEmpty(BackgroundRepeat)) { element.Add(new XAttribute("background-repeat", BackgroundRepeat)); } if (KeepTogether != FoKeepTogether.Inherit) { element.Add(new XAttribute("keep-together", ToKebabCase(KeepTogether))); } if (!string.IsNullOrEmpty(LineHeight)) { element.Add(new XAttribute("line-height", LineHeight)); } if (!string.IsNullOrEmpty(Width)) { element.Add(new XAttribute("width", Width)); } if (!string.IsNullOrEmpty(Height)) { element.Add(new XAttribute("height", Height)); } if (!string.IsNullOrEmpty(Margin)) { element.Add(new XAttribute("margin", Margin)); } if (!string.IsNullOrEmpty(MarginTop)) { element.Add(new XAttribute("margin-top", MarginTop)); } if (!string.IsNullOrEmpty(MarginRight)) { element.Add(new XAttribute("margin-right", MarginRight)); } if (!string.IsNullOrEmpty(MarginBottom)) { element.Add(new XAttribute("margin-bottom", MarginBottom)); } if (!string.IsNullOrEmpty(MarginLeft)) { element.Add(new XAttribute("margin-left", MarginLeft)); } if (!string.IsNullOrEmpty(Padding)) { element.Add(new XAttribute("padding", Padding)); } if (!string.IsNullOrEmpty(PaddingTop)) { element.Add(new XAttribute("padding-top", PaddingTop)); } if (!string.IsNullOrEmpty(PaddingRight)) { element.Add(new XAttribute("padding-right", PaddingRight)); } if (!string.IsNullOrEmpty(PaddingBottom)) { element.Add(new XAttribute("padding-bottom", PaddingBottom)); } if (!string.IsNullOrEmpty(PaddingLeft)) { element.Add(new XAttribute("padding-left", PaddingLeft)); } if (!string.IsNullOrEmpty(Border)) { element.Add(new XAttribute("border", Border)); } if (!string.IsNullOrEmpty(BorderTop)) { element.Add(new XAttribute("border-top", BorderTop)); } if (!string.IsNullOrEmpty(BorderRight)) { element.Add(new XAttribute("border-right", BorderRight)); } if (!string.IsNullOrEmpty(BorderBottom)) { element.Add(new XAttribute("border-bottom", BorderBottom)); } if (!string.IsNullOrEmpty(BorderLeft)) { element.Add(new XAttribute("border-left", BorderLeft)); } #endregion }