pub fn render(html: &str, config: Config) -> Result<Vec<u8>>Expand description
Render HTML content to the specified output format.
This is the main entry point for rendering HTML. It parses the HTML, computes styles and layout, and renders to the format specified in the config.
§Arguments
html- The HTML content to renderconfig- Rendering configuration (dimensions, format, scale, etc.)
§Returns
Returns the rendered output as bytes (PNG image data or PDF document).
§Errors
Returns an error if:
- Configuration is invalid (zero dimensions, non-positive scale)
- HTML parsing fails
- Layout computation fails
- Rendering fails
- The requested output format feature is not enabled
§Example
use hyper_render::{render, Config, OutputFormat};
let html = "<h1>Hello</h1>";
// PNG output (default)
let png = render(html, Config::default())?;
// PDF output
let pdf = render(html, Config::default().format(OutputFormat::Pdf))?;