HtmlRender
Standalone static class for simple and direct HTML rendering. For WPF UI prefer using HTML controls: HtmlPanel or HtmlLabel. For low-level control and performance consider using HtmlContainer.
Métodos
AddFontFamily(FontFamily)
Adds a font family to be used in html rendering. The added font will be used by all rendering function including HtmlContainer and all WPF controls.
- fontFamily
- The font family to add.
AddFontFamilyMapping(string, string)
Adds a font mapping from to iff the is not found. When the font is used in rendered html and is not found in existing fonts (installed or added) it will be replaced by .
- fromFamily
- the font family to replace
- toFamily
- the font family to replace with
Measure(string, double, CssData, EventHandler<HtmlStylesheetLoadEventArgs>, EventHandler<HtmlImageLoadEventArgs>) : Size
Measure the size (width and height) required to draw the given html under given max width restriction. If no max width restriction is given the layout will use the maximum possible width required by the content, it can be the longest text line or full image width.
- html
- HTML source to render
- maxWidth
- optional: bound the width of the html to render in (default - 0, unlimited)
- cssData
- optional: the style to use for html rendering (default - use W3 default style)
- stylesheetLoad
- optional: can be used to overwrite stylesheet resolution logic
- imageLoad
- optional: can be used to overwrite image resolution logic
Devuelve: the size required for the html
MeasureHtmlByRestrictions(HtmlContainer, Size, Size) : Size
Measure the size of the html by performing layout under the given restrictions.
- htmlContainer
- the html to calculate the layout for
- minSize
- the minimal size of the rendered html (zero - not limit the width/height)
- maxSize
- the maximum size of the rendered html, if not zero and html cannot be layout within the limit it will be clipped (zero - not limit the width/height)
Devuelve: return: the size of the html to be rendered within the min/max limits
ParseStyleSheet(string, bool) : CssData
Parse the given stylesheet to CssData object. If is true the parsed css blocks are added to the default css data (as defined by W3), merged if class name already exists. If false only the data in the given stylesheet is returned.
- stylesheet
- the stylesheet source to parse
- combineWithDefault
- true - combine the parsed css data with default css data, false - return only the parsed css data
Devuelve: the parsed css data
Render(DrawingContext, string, double, double, double, CssData, EventHandler<HtmlStylesheetLoadEventArgs>, EventHandler<HtmlImageLoadEventArgs>) : Size
Renders the specified HTML source on the specified location and max width restriction. If is zero the html will use all the required width, otherwise it will perform line wrap as specified in the html Returned is the actual width and height of the rendered html.
- g
- Device to render with
- html
- HTML source to render
- left
- optional: the left most location to start render the html at (default - 0)
- top
- optional: the top most location to start render the html at (default - 0)
- maxWidth
- optional: bound the width of the html to render in (default - 0, unlimited)
- cssData
- optional: the style to use for html rendering (default - use W3 default style)
- stylesheetLoad
- optional: can be used to overwrite stylesheet resolution logic
- imageLoad
- optional: can be used to overwrite image resolution logic
Devuelve: the actual size of the rendered html
Render(DrawingContext, string, Point, Size, CssData, EventHandler<HtmlStylesheetLoadEventArgs>, EventHandler<HtmlImageLoadEventArgs>) : Size
Renders the specified HTML source on the specified location and max size restriction. If .Width is zero the html will use all the required width, otherwise it will perform line wrap as specified in the html If .Height is zero the html will use all the required height, otherwise it will clip at the given max height not rendering the html below it. Returned is the actual width and height of the rendered html.
- g
- Device to render with
- html
- HTML source to render
- location
- the top-left most location to start render the html at
- maxSize
- the max size of the rendered html (if height above zero it will be clipped)
- cssData
- optional: the style to use for html rendering (default - use W3 default style)
- stylesheetLoad
- optional: can be used to overwrite stylesheet resolution logic
- imageLoad
- optional: can be used to overwrite image resolution logic
Devuelve: the actual size of the rendered html
RenderClip(DrawingContext, string, Point, Size, CssData, EventHandler<HtmlStylesheetLoadEventArgs>, EventHandler<HtmlImageLoadEventArgs>) : Size
Renders the specified HTML source on the specified location and max size restriction. If .Width is zero the html will use all the required width, otherwise it will perform line wrap as specified in the html If .Height is zero the html will use all the required height, otherwise it will clip at the given max height not rendering the html below it. Clip the graphics so the html will not be rendered outside the max height bound given. Returned is the actual width and height of the rendered html.
- g
- Device to render with
- html
- HTML source to render
- location
- the top-left most location to start render the html at
- maxSize
- the max size of the rendered html (if height above zero it will be clipped)
- cssData
- optional: the style to use for html rendering (default - use W3 default style)
- stylesheetLoad
- optional: can be used to overwrite stylesheet resolution logic
- imageLoad
- optional: can be used to overwrite image resolution logic
Devuelve: the actual size of the rendered html
RenderHtml(DrawingContext, string, Point, Size, CssData, EventHandler<HtmlStylesheetLoadEventArgs>, EventHandler<HtmlImageLoadEventArgs>) : Size
Renders the specified HTML source on the specified location and max size restriction. If .Width is zero the html will use all the required width, otherwise it will perform line wrap as specified in the html If .Height is zero the html will use all the required height, otherwise it will clip at the given max height not rendering the html below it. Returned is the actual width and height of the rendered html.
- g
- Device to render with
- html
- HTML source to render
- location
- the top-left most location to start render the html at
- maxSize
- the max size of the rendered html (if height above zero it will be clipped)
- cssData
- optional: the style to use for html rendering (default - use W3 default style)
- stylesheetLoad
- optional: can be used to overwrite stylesheet resolution logic
- imageLoad
- optional: can be used to overwrite image resolution logic
Devuelve: the actual size of the rendered html
RenderToImage(string, Size, CssData, EventHandler<HtmlStylesheetLoadEventArgs>, EventHandler<HtmlImageLoadEventArgs>) : BitmapFrame
Renders the specified HTML into a new image of the requested size. The HTML will be layout by the given size but will be clipped if cannot fit.
- html
- HTML source to render
- size
- The size of the image to render into, layout html by width and clipped by height
- cssData
- optional: the style to use for html rendering (default - use W3 default style)
- stylesheetLoad
- optional: can be used to overwrite stylesheet resolution logic
- imageLoad
- optional: can be used to overwrite image resolution logic
Devuelve: the generated image of the html
RenderToImage(string, int, int, Color, CssData, EventHandler<HtmlStylesheetLoadEventArgs>, EventHandler<HtmlImageLoadEventArgs>) : BitmapFrame
Renders the specified HTML into a new image of unknown size that will be determined by max width/height and HTML layout. If is zero the html will use all the required width, otherwise it will perform line wrap as specified in the html If is zero the html will use all the required height, otherwise it will clip at the given max height not rendering the html below it. Limitation: The image cannot have transparent background, by default it will be white. See "Rendering to image" remarks section on HtmlRender.
- html
- HTML source to render
- maxWidth
- optional: the max width of the rendered html, if not zero and html cannot be layout within the limit it will be clipped
- maxHeight
- optional: the max height of the rendered html, if not zero and html cannot be layout within the limit it will be clipped
- backgroundColor
- optional: the color to fill the image with (default - white)
- cssData
- optional: the style to use for html rendering (default - use W3 default style)
- stylesheetLoad
- optional: can be used to overwrite stylesheet resolution logic
- imageLoad
- optional: can be used to overwrite image resolution logic
Devuelve: the generated image of the html
RenderToImage(string, Size, Size, Color, CssData, EventHandler<HtmlStylesheetLoadEventArgs>, EventHandler<HtmlImageLoadEventArgs>) : BitmapFrame
Renders the specified HTML into a new image of unknown size that will be determined by min/max width/height and HTML layout. If is zero the html will use all the required width, otherwise it will perform line wrap as specified in the html If is zero the html will use all the required height, otherwise it will clip at the given max height not rendering the html below it. If (Width/Height) is above zero the rendered image will not be smaller than the given min size. Limitation: The image cannot have transparent background, by default it will be white. See "Rendering to image" remarks section on HtmlRender.
- html
- HTML source to render
- minSize
- optional: the min size of the rendered html (zero - not limit the width/height)
- maxSize
- optional: the max size of the rendered html, if not zero and html cannot be layout within the limit it will be clipped (zero - not limit the width/height)
- backgroundColor
- optional: the color to fill the image with (default - white)
- cssData
- optional: the style to use for html rendering (default - use W3 default style)
- stylesheetLoad
- optional: can be used to overwrite stylesheet resolution logic
- imageLoad
- optional: can be used to overwrite image resolution logic
Devuelve: the generated image of the html