Quantcast
Channel: HtmlRenderer Wiki & Documentation Rss Feed
Viewing all 73 articles
Browse latest View live

Updated Wiki: HTML and CSS support

$
0
0

HTML and CSS specification

  • HTML 4.01
  • CSS level 2

Additional features

Jose took the liberty of adding a couple of features:
  • Background gradients
  • Rounded corners
These are achieved thru the following CSS properties:
  • background-gradient: (color)
  • background-gradient-angle: (number)
  • corner-ne-radius: (length)
  • corner-nw-radius: (length)
  • corner-se-radius: (length)
  • corner-se-radius: (length)
  • corner-radius: (length){1,4} (shorthand for all corners)

Note
  • When using rounded corners with borders, you must prevent the corner radius to be larger than the border thickness.

Updated Wiki: Home

$
0
0
The rich formatting power of HTML in your .NET applications using simple controls or static rendering code.
The library is 100% managed C# code without any external dependencies (no WebBrowser control, ActiveX / COM or MSHTML dll), the only requirement is .NET 2.0 or higher.

Download the Demo application to explore HTML Renderer capabilities.

Renderer1.png

Features and Benefits

  • Extensive HTML 4.01 and CSS level 2 specifications support.
  • Support separating CSS from HTML by loading stylesheet code separately.
  • Support text selection, copy-paste and context menu.
  • WinForms controls: HtmlPanel, HtmlLabel and HtmlToolTip.
  • Create images from HTML snippets.
  • Handles "real world" malformed HTML, it doesn't have to be XHTML.
  • 100% managed code and no external dependencies.
  • Supports .NET 2.0 or higher including Client Profile.
  • Lightweight single dll (~250K).
  • High performance and low memory footprint.
  • Extendable and configurable.
  • Powerful Demo application to explore and learn the library.

WinForms controls

  • HtmlPanel - The full power of HTML control build to replace WinForms WebBrowser control, accepts HTML, text selection, scrollbars, link click intercept, image load intercept and much more.
  • HtmlLabel - As WinForms label but accepts HTML, text selection, auto-size capabilities, transparent background and more.
  • HtmlToolTip - As WinForms ToolTip control but accepts HTML and ability to handle links.

Sample application

  • Render HTML content generated by rich web editors like forums, blogs, etc.
  • Render Office documents converted to HTML.
  • Create complex WinForms UI with HTML instead of numerous WinForms controls with complex layout logic.
  • Create WinForms UI that requires text selection with clipboard support.
  • Create images from HTML code snippets.

NuGet package install

NuGet package

Manual install

  • Download the binaries.
  • Reference the proper .NET release (2.0, 3.5, 4.0, 4.5) in your project.

Usage

  • Add HtmlRenderer to Visual Studio Toolbox (drag-drop the dll on it).
  • Drag-n-drop HtmlPanel, HtmlLabel or HtmlToolTip from the Toolbox.
  • Set the Text property with your HTML.

Source

Authors

Updated Wiki: Demo application

$
0
0
The HTML Renderer Demo application has three roles:
1. Showcase the HTML Renderer capabilities with build in htmls.
2. Explore and test HTML Renderer capabilities by editing html text and seeing the rendering immediately.
3. Development tool for HTML Renderer.

Showcase HTML renderer capabilities

Demo1.png
Figure 1: See showcase examples in the tree to the left (Intro, History, Text, Tables, Links, etc.)

Edit html directly in editor and see the renderer refresh

Demo2.png
Figure 2: Added color="red" attribute and see the rendered html updates

See the different WinForms controls support using "Sample Form"

Demo3.png
Figure 3: Open "Sample Form" to see the HtmlLabel control in-action.

See the ToolTip

Demo3.png
Figure 4: HTML ToolTip shown.

Updated Wiki: Demo application

$
0
0
The HTML Renderer Demo application has three roles:
1. Showcase the HTML Renderer capabilities with build in htmls.
2. Explore and test HTML Renderer capabilities by editing html text and seeing the rendering immediately.
3. Development tool for HTML Renderer.

Showcase HTML renderer capabilities

Demo1.png
Figure 1: See showcase examples in the tree to the left (Intro, History, Text, Tables, Links, etc.)

Edit html directly in editor and see the renderer refresh

Demo2.png
Figure 2: Added color="red" attribute and see the rendered html updates

See the different WinForms controls support using "Sample Form"

Demo3.png
Figure 3: Open "Sample Form" to see the HtmlLabel control in-action.

See the ToolTip

Demo4.png
Figure 4: HTML ToolTip shown.



Updated Wiki: Image generation

$
0
0
HTML Renderer can be used to generate image (pmg, jpeg, bmp...) from HTML markup string.

Simple fixed size image

Updated Wiki: Documentation

$
0
0
The rich formating power of HTML in your .NET applications without WebBrowser control or MSHTML.

Navigation:

Features and Benefits

  • Extensive HTML 4.01 and CSS 2 specifications support.
  • Support separating CSS from HTML by loading stylesheet code separately.
  • Support text selection, copy-paste and context menu.
  • WinForms controls: HtmlPanel, HtmlLabel and HtmlToolTip.
  • Create images from html snippets.
  • 100% managed code and no external dependencies.
  • Supports .NET 2.0 or higher including Client Profile.
  • Lightweight single dll (~250K).
  • High performance and low memory footprint.
  • Extendable and configurable.
  • Powerful Demo application to explore and learn the library.

Getting Started

  • Download the binaries.
  • Run the Demo application
    • Check HTMLs showcasing renderer capabilities.
    • Paste your own HTML to see the power of the renderer.
  • Add the dll to Visual Studio Toolbox
  • Drag-n-drop Html WinForms controls on your controls.
  • Set the Text property with HTML and see it renders.

History

For years, I (Jose) have been planning for a project like this. I prepared my self quite well. I went through the entire CSS Level 2 specification along with the HTML 4.01 specification.

One of the most interesting things I found is this: Drawing HTML is no more than laying out a bunch of boxes with borders margins and padding's. Once you overpass this paradigm, everything else is to help the code actually place the boxes on the right place, and then paint the string each box contains.

In October 2012 I (Arthur) was looking to replace the usage of WinForms WebBrowser control by something that can render complex html and have good performance and stability characteristics.

HTML Renderer project showed great promise but had significant performance issues, lacked many features and wasn't updated for more than 3 years. Realizing there is no alternative I embraced the project making it my baby.

...

See Also

Updated Wiki: Rendering SVG images

$
0
0

Rendering SVG images in HTML Renderer

.NET framework doesn't support SVG format so HTML Renderer cannot natively load and render it.
To overcome this limitation a third-party library can be used to convert SVG formatted image to PNG formatted image that can be rendered by .NET.
It can be done using "ImageLoad" delegate/event that allows to intercept image loading and overwrite SVG image loading with converted PNG image.

Example

Generate image from HTML containing SVG image
Using SVG open-source project added using NuGet package.
Rendering this SVG image.

string html = "<body><h3>Rendered <b>SVG</b> image</h3><hr/><img src='d:\\svg.svg'/></body>";
CssData css = CssData.Parse("body { font:14pt Tahoma } h3 { color: navy; font-weight:normal; }");
Image generatedImage = HtmlRender.RenderToImage(html, cssData: css, imageLoad: (sender, args) =>
{
    var path = Path.GetExtension(args.Src);
    if( path != null && path.Equals(".svg", StringComparison.OrdinalIgnoreCase) )
    {
        SvgDocument svgDoc = SvgDocument.Open(args.Src);
        Bitmap svgImg = new Bitmap((int)svgDoc.Width, (int)svgDoc.Height, PixelFormat.Format32bppArgb);
        svgDoc.Draw(svgImg);
        args.Callback(svgImg);
    }
});
generatedImage.Save(@"d:\html.png", ImageFormat.Png);

Output

Updated Wiki: Documentation

$
0
0
The rich formating power of HTML in your .NET applications without WebBrowser control or MSHTML.

Navigation:

Features and Benefits

  • Extensive HTML 4.01 and CSS 2 specifications support.
  • Support separating CSS from HTML by loading stylesheet code separately.
  • Support text selection, copy-paste and context menu.
  • WinForms controls: HtmlPanel, HtmlLabel and HtmlToolTip.
  • Create images from html snippets.
  • 100% managed code and no external dependencies.
  • Supports .NET 2.0 or higher including Client Profile.
  • Lightweight single dll (~250K).
  • High performance and low memory footprint.
  • Extendable and configurable.
  • Powerful Demo application to explore and learn the library.

Getting Started

  • Download the binaries.
  • Run the Demo application
    • Check HTMLs showcasing renderer capabilities.
    • Paste your own HTML to see the power of the renderer.
  • Add the dll to Visual Studio Toolbox
  • Drag-n-drop Html WinForms controls on your controls.
  • Set the Text property with HTML and see it renders.

History

For years, I (Jose) have been planning for a project like this. I prepared my self quite well. I went through the entire CSS Level 2 specification along with the HTML 4.01 specification.

One of the most interesting things I found is this: Drawing HTML is no more than laying out a bunch of boxes with borders margins and padding's. Once you overpass this paradigm, everything else is to help the code actually place the boxes on the right place, and then paint the string each box contains.

In October 2012 I (Arthur) was looking to replace the usage of WinForms WebBrowser control by something that can render complex html and have good performance and stability characteristics.

HTML Renderer project showed great promise but had significant performance issues, lacked many features and wasn't updated for more than 3 years. Realizing there is no alternative I embraced the project making it my baby.

...

See Also


Updated Wiki: Rendering SVG images

$
0
0

Rendering SVG images in HTML Renderer

.NET framework doesn't support SVG format so HTML Renderer cannot natively load and render it.
To overcome this limitation a third-party library can be used to convert SVG formatted image to PNG formatted image that can be rendered by .NET.
It can be done using "ImageLoad" delegate/event that allows to intercept image loading and overwrite SVG image loading with converted PNG image.

Example

Generate image from HTML containing SVG image
Using SVG open-source project added using NuGet package.
Rendering this SVG image.

string html = "<body><h3>Rendered <b>SVG</b> image</h3><hr/><img src='d:\\svg.svg'/></body>";
CssData css = CssData.Parse("body { font:14pt Tahoma } h3 { color: navy; font-weight:normal; }");
Image generatedImage = HtmlRender.RenderToImage(html, cssData: css, imageLoad: (sender, args) =>
{
    var path = Path.GetExtension(args.Src);
    if( path != null && path.Equals(".svg", StringComparison.OrdinalIgnoreCase) )
    {
        SvgDocument svgDoc = SvgDocument.Open(args.Src);
        Bitmap svgImg = new Bitmap((int)svgDoc.Width, (int)svgDoc.Height, PixelFormat.Format32bppArgb);
        svgDoc.Draw(svgImg);
        args.Callback(svgImg);
    }
});
generatedImage.Save(@"d:\html.png", ImageFormat.Png);

Output

html.png

Updated Wiki: FAQ

$
0
0
Why SVG images not working?
.NET doesn't support SVG format.
A workaround is to convert SVG to PNG during rendering, see Rendering SVG images.

Will there be WPF support?
Yes, I'm planning to extend HTML Renderer to support different UI frameworks.

What about Java Script?
Java script support is extremely hard to support so it is not on the road-map.

Why can't I navigate to a URL?
HTML Renderer is not a web-browser.

Can I contribute?
Sure! go to ArthurHub on GitHub and fork away.


Updated Wiki: Documentation

$
0
0
The rich formating power of HTML in your .NET applications without WebBrowser control or MSHTML.

Navigation:

Getting Started

  • Download the binaries.
  • Run the Demo application
    • Check HTMLs showcasing renderer capabilities.
    • Paste your own HTML to see the power of the renderer.
  • Add the dll to Visual Studio Toolbox
  • Drag-n-drop Html WinForms controls on your controls.
  • Set the Text property with HTML and see it renders.

History

For years, I (Jose) have been planning for a project like this. I prepared my self quite well. I went through the entire CSS Level 2 specification along with the HTML 4.01 specification.

One of the most interesting things I found is this: Drawing HTML is no more than laying out a bunch of boxes with borders margins and padding's. Once you overpass this paradigm, everything else is to help the code actually place the boxes on the right place, and then paint the string each box contains.

In October 2012 I (Arthur) was looking to replace the usage of WinForms WebBrowser control by something that can render complex html and have good performance and stability characteristics.

HTML Renderer project showed great promise but had significant performance issues, lacked many features and wasn't updated for more than 3 years. Realizing there is no alternative I embraced the project making it my baby.

...

See Also

Updated Wiki: Documentation

$
0
0
The rich formating power of HTML in your .NET applications without WebBrowser control or MSHTML.

Navigation:

Getting Started

  • Download the binaries.
  • Run the Demo application
    • Check HTMLs showcasing renderer capabilities.
    • Paste your own HTML to see the power of the renderer.
  • Add the dll to Visual Studio Toolbox
  • Drag-n-drop Html WinForms controls on your controls.
  • Set the Text property with HTML and see it renders.

History

For years, I (Jose) have been planning for a project like this. I prepared my self quite well. I went through the entire CSS Level 2 specification along with the HTML 4.01 specification.

One of the most interesting things I found is this: Drawing HTML is no more than laying out a bunch of boxes with borders margins and padding's. Once you overpass this paradigm, everything else is to help the code actually place the boxes on the right place, and then paint the string each box contains.

In October 2012 I (Arthur) was looking to replace the usage of WinForms WebBrowser control by something that can render complex html and have good performance and stability characteristics.

HTML Renderer project showed great promise but had significant performance issues, lacked many features and wasn't updated for more than 3 years. Realizing there is no alternative I embraced the project making it my baby.

...

See Also

Updated Wiki: Home

$
0
0
The rich formatting power of HTML in your .NET applications using simple controls or static rendering code.
The library is 100% managed C# code without any external dependencies (no WebBrowser control, ActiveX / COM or MSHTML dll), the only requirement is .NET 2.0 or higher.

Renderer1.png

Features and Benefits

  • Extensive HTML 4.01 and CSS level 2 specifications support.
  • Support separating CSS from HTML by loading stylesheet code separately.
  • Support text selection, copy-paste and context menu.
  • WinForms controls: HtmlPanel, HtmlLabel and HtmlToolTip.
  • Create images from HTML snippets.
  • Handles "real world" malformed HTML, it doesn't have to be XHTML.
  • 100% managed code and no external dependencies.
  • Supports .NET 2.0 or higher including Client Profile.
  • Lightweight single dll (~250K).
  • High performance and low memory footprint.
  • Extendable and configurable.
  • Powerful Demo application to explore and learn the library.

WinForms controls

  • HtmlPanel - The full power of HTML control build to replace WinForms WebBrowser control, accepts HTML, text selection, scrollbars, link click intercept, image load intercept and much more.
  • HtmlLabel - As WinForms label but accepts HTML, text selection, auto-size capabilities, transparent background and more.
  • HtmlToolTip - As WinForms ToolTip control but accepts HTML and ability to handle links.

Sample application

  • Render HTML content generated by rich web editors like forums, blogs, etc.
  • Render Office documents converted to HTML.
  • Create complex WinForms UI with HTML instead of numerous WinForms controls with complex layout logic.
  • Create WinForms UI that requires text selection with clipboard support.
  • Create images from HTML code snippets.

NuGet package install

NuGet package

Manual install

  • Download the binaries.
  • Reference the proper .NET release (2.0, 3.5, 4.0, 4.5) in your project.

Usage

  • Add HtmlRenderer to Visual Studio Toolbox (drag-drop the dll on it).
  • Drag-n-drop HtmlPanel, HtmlLabel or HtmlToolTip from the Toolbox.
  • Set the Text property with your HTML.

Source

Authors

Updated Wiki: Image generation

$
0
0

Generate image from HTML markup

HTML Renderer can be used to generate image (pmg, jpeg, bmp...) from HTML markup string.
Because of GDI text rendering issue with alpha channel clear type text rendering rendering to image requires special handling.

HTML used in examples

Solid color background

Simple fixed size image


Min/Max size restrictions


Image background


Transparent background


GDI vs. GDI+

Image loading optimization




Updated Wiki: Image generation

$
0
0

Generate image from HTML markup

HTML Renderer can be used to generate image (pmg, jpeg, bmp...) from HTML markup string.
Because of GDI text rendering issue with alpha channel clear type text rendering rendering to image requires special handling.

HTML used in examples

img.png

Solid color background

Simple fixed size image


Min/Max size restrictions


Image background


Transparent background


GDI vs. GDI+

Image loading optimization





Updated Wiki: Image generation

$
0
0

Generate image from HTML markup

HTML Renderer can be used to generate image (pmg, jpeg, bmp...) from HTML markup string.
Because of GDI text rendering issue with alpha channel clear type text rendering rendering to image requires special handling.

HTML used in examples

img.png
<body style="font: 10pt Tahoma">
    <h3 style="color: navy; margin-bottom: 8px">Render to Image</h3>
    <hr />
    <table style="border: 1px solid maroon; width: 100%; margin-top: 5px">
        <tr style="vertical-align: top;">
            <td width="32" style="padding: 2px 5px 0 0">
                <img src="http://download-codeplex.sec.s-msft.com/Download?ProjectName=HtmlRenderer&DownloadId=770243" />
            </td>
            <td>This <i>text</i> is inside a <b>table</b> <u>element</u>.<br />
                Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur ornare mollis elit.
            </td>
        </tr>
    </table>
    <ul style="margin-top: 5px">
        <li><span style="color: red">Colors</span></li>
        <li><span style="background-color: #8dd">Back colors</span></li>
    </ul>
</body>

Solid color background

Simple fixed size image


Min/Max size restrictions


Image background


Transparent background


GDI vs. GDI+

Image loading optimization




Updated Wiki: Image generation

$
0
0

Generate image from HTML markup

HTML Renderer can be used to generate image (pmg, jpeg, bmp...) from HTML markup string.
Because of GDI text rendering issue with alpha channel clear type text rendering rendering to image requires special handling.

  1. Generate image with solid color background
  2. Generate image with image background
  3. Generate image with transparent background

HTML used in examples

img.png
<body style="font: 10pt Tahoma">
    <h3 style="color: navy; margin-bottom: 8px">Render to Image</h3>
    <hr />
    <table style="border: 1px solid maroon; margin-top: 5px">
        <tr style="vertical-align: top;">
            <td width="32" style="padding: 2px 0 0 0">
                <img src="http://download-codeplex.sec.s-msft.com/Download?ProjectName=HtmlRenderer&DownloadId=770243" />
            </td>
            <td>This <i>text</i> is inside a <b>table</b> <u>element</u>.<br />
                Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur ornare mollis elit.
            </td>
        </tr>
    </table>
    <ul style="margin-top: 5px">
        <li><span style="color: red">Colors</span></li>
        <li><span style="background-color: #8dd">Back colors</span></li>
    </ul>
</body>


Solid color background

No size restrictions

Image image = HtmlRender.RenderToImage(html);
  • Generated image size depends on HTML content greedy layout.
    • Width will be set by the longest line without wrapping.
    • Height will be set by exact height of the HTML.
  • The default background color is used - white.
html0.png

Fixed size image

Image image = HtmlRender.RenderToImage(html, new Size(400, 200), Color.Linen);
  • Generate image of fixed size - 400x200 pixels.
  • HTML layout is restricted by max width - 400 pixels.
  • Image heights extend beyond the actual height of the HTML.
    • If image height was smaller than actual HTML height the rendered HTML would be clipped.
  • Use Color.Linen solid background color.
html1.png

Min/Max size restrictions



Image background



Transparent background


GDI vs. GDI+

Image loading optimization




Updated Wiki: FAQ

$
0
0
Why SVG images are not working?
.NET doesn't support SVG format.
A workaround is to convert SVG to PNG during rendering, see Rendering SVG images.

Will there be WPF support?
Yes, I'm planning to extend HTML Renderer to support different UI frameworks.

What about Java Script?
Java script is extremely hard to support so it is not on the road-map.

Why can't I navigate to a URL?
HTML Renderer is not a web-browser.

Can I contribute?
Sure! go to ArthurHub on GitHub and fork away.


Updated Wiki: Image generation

$
0
0

Generate image from HTML markup

HTML Renderer can be used to generate image (pmg, jpeg, bmp...) from HTML markup string.
Because of GDI text rendering issue with alpha channel and clear type text rendering, rendering to image requires special handling.

  1. Generate image with solid color background
  2. Generate image with image background
  3. Generate image with transparent background

HTML used in examples

img.png
<body style="font: 10pt Tahoma">
    <h3 style="color: navy; margin-bottom: 8px">Render to Image</h3>
    <hr />
    <table style="border: 1px solid maroon; margin-top: 5px">
        <tr style="vertical-align: top;">
            <td width="32" style="padding: 2px 0 0 0">
                <img src="http://download-codeplex.sec.s-msft.com/Download?ProjectName=HtmlRenderer&DownloadId=770243" />
            </td>
            <td>This <i>text</i> is inside a <b>table</b> <u>element</u>.<br />
                Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur ornare mollis elit.
            </td>
        </tr>
    </table>
    <ul style="margin-top: 5px">
        <li><span style="color: red">Colors</span></li>
        <li><span style="background-color: #8dd">Back colors</span></li>
    </ul>
</body>

Expected result (as rendered in Google Chrome):
Expected.png

Solid color background

No size restrictions

Image image = HtmlRender.RenderToImage(html);
  • Generated image size depends on HTML content greedy layout.
    • Width will be set by the longest line without wrapping.
    • Height will be set by exact height of the HTML.
  • The default background color is used - white.
html0.png

Fixed size image

Image image = HtmlRender.RenderToImage(html, new Size(400, 200), Color.Linen);
  • Generate image of fixed size - 400x200 pixels.
  • HTML layout is restricted by max width - 400 pixels.
  • Image heights extend beyond the actual height of the HTML.
    • If image height was smaller than actual HTML height the rendered HTML would be clipped.
  • Use Color.Linen solid background color.
html1.png

Min/Max size restrictions



Image background



Transparent background


GDI vs. GDI+

Image loading optimization




Updated Wiki: Image generation

$
0
0

Generate image from HTML markup

HTML Renderer can be used to generate image (pmg, jpeg, bmp...) from HTML markup string.
Because of GDI text rendering issue with alpha channel and clear type text rendering, rendering to image requires special handling.

  1. Generate image with solid color background
  2. Generate image with image background
  3. Generate image with transparent background

HTML used in examples

img.png
<body style="font: 10pt Tahoma">
    <h3 style="color: navy; margin-bottom: 8px">Render to Image</h3>
    <hr />
    <table style="border: 1px solid maroon; margin-top: 5px">
        <tr style="vertical-align: top;">
            <td width="32" style="padding: 2px 0 0 0">
                <img src="http://download-codeplex.sec.s-msft.com/Download?ProjectName=HtmlRenderer&DownloadId=770243" />
            </td>
            <td>This <i>text</i> is inside a <b>table</b> <u>element</u>.<br />
                Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur ornare mollis elit.
            </td>
        </tr>
    </table>
    <ul style="margin-top: 5px">
        <li><span style="color: red">Colors</span></li>
        <li><span style="background-color: #8dd">Back colors</span></li>
    </ul>
</body>

Expected result (as rendered in Google Chrome):
Expected.png

Solid color background

No size restrictions

Image image = HtmlRender.RenderToImage(html);
  • Generated image size depends on HTML content greedy layout.
    • Width will be set by the longest line without wrapping.
    • Height will be set by exact height of the HTML.
  • The default background color is used - white.
html0.png

Fixed size image

Image image = HtmlRender.RenderToImage(html, new Size(400, 200), Color.Linen);
  • Generate image of fixed size - 400x200 pixels.
  • HTML layout is restricted by max width - 400 pixels.
    • Text is wrapped to to fir into the restricted width.
  • Image heights extend beyond the actual height of the HTML.
    • If image height was smaller than actual HTML height the rendered HTML would be clipped.
  • Use Color.Linen solid background color.
html1.png

Min/Max size restrictions

Image image = HtmlRender.RenderToImage(html, new Size(650, 50), new Size(1400, 106), Color.SeaShell);

  • Generate image with minimum and maximum size restrictions.
  • Restricted max width is above the max required width to layout the longest text without wrapping so it has no effect.
  • Restricted min width is also above the required layout width (541px) therefore the html is extended.
  • the resulting image width is 650px and the html uses the full width to layout.
  • Restricted max height is lower than the required height to fully render the html therefore it is clipped at the restricted height value: 106px.
html2.png

Image background



Transparent background


GDI vs. GDI+

Image loading optimization




Viewing all 73 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>