Skip to main content
OfficeIMO Docs Search documentation/

Render and Convert HTML

Edit on GitHub

Parse HTML or MHTML, control resource access, render images, and convert web content into Office and PDF artifacts.

OfficeIMO.Html owns HTML/MHTML parsing, archive resources, URL policy, bounded layout, and image rendering. Destination adapters reuse the same engine so Word, Markdown, RTF, Email, PDF, and EPUB workflows do not each invent another HTML parser.

Render HTML to an image

using OfficeIMO.Html;

HtmlConversionDocument source = HtmlConversionDocument.Parse(
    "<h1>Status</h1><p>Generated by OfficeIMO.</p>");

byte[] png = source.ToPng(new HtmlRenderOptions {
    ViewportWidth = 720,
    Scale = 1.5
});

File.WriteAllBytes("status.png", png);

The renderer supports continuous or paged layout and PNG, JPEG, TIFF, SVG, and WebP output. Apply output-pixel and source-resource limits before accepting arbitrary uploads.

Choose a destination adapter

DestinationPackage
PDFOfficeIMO.Html.Pdf
WordOfficeIMO.Word.Html
MarkdownOfficeIMO.Markdown.Html
RTFOfficeIMO.Html with the focused RTF adapter
Reader resultsOfficeIMO.Reader.Html

The generated output gallery includes a runnable invoice workflow with a downloadable PDF and the PNG rendered from the same HTML document and options object.

Control resources

Set a resource policy for network URLs, file URLs, data URLs, archive entries, image size, and total expansion. A service handling uploaded HTML should default to no external network or filesystem access and supply approved resources explicitly.

Use semantic conversion when editable headings, paragraphs, lists, links, and tables matter most. Use visual rendering when page appearance is the primary contract.