MarkdownToImageLibrary 1.1.0
See the version list below for details.
dotnet add package MarkdownToImageLibrary --version 1.1.0
NuGet\Install-Package MarkdownToImageLibrary -Version 1.1.0
<PackageReference Include="MarkdownToImageLibrary" Version="1.1.0" />
<PackageVersion Include="MarkdownToImageLibrary" Version="1.1.0" />
<PackageReference Include="MarkdownToImageLibrary" />
paket add MarkdownToImageLibrary --version 1.1.0
#r "nuget: MarkdownToImageLibrary, 1.1.0"
#:package MarkdownToImageLibrary@1.1.0
#addin nuget:?package=MarkdownToImageLibrary&version=1.1.0
#tool nuget:?package=MarkdownToImageLibrary&version=1.1.0
Markdown to Image Converter
A .NET application that processes markdown files to extract HTML/CSS sections and converts them to images using wkhtmltoimage.exe.
Features
- Extracts HTML sections from markdown files (content within
html
blocks) - Converts each HTML section to a PNG image using wkhtmltoimage
- Handles CSS styles embedded within HTML sections
- Creates complete HTML documents with proper structure
- Saves generated images in an
images
folder - Supports multiple HTML sections per markdown file
Prerequisites
- .NET 8.0 SDK - Download from https://dotnet.microsoft.com/download
- wkhtmltoimage - Download from https://wkhtmltopdf.org/downloads.html
Installing wkhtmltoimage
- Download the wkhtmltopdf installer for Windows
- Install it (default location:
C:\Program Files\wkhtmltopdf\bin\wkhtmltoimage.exe
) - Optionally add the installation directory to your PATH environment variable
Build and Run
Restore dependencies:
dotnet restore
Build the application:
dotnet build
Run the application:
dotnet run --project MarkdownToImageConverter.csproj sample.md
Or specify the path to wkhtmltoimage.exe if it's not in PATH:
dotnet run --project MarkdownToImageConverter.csproj sample.md "C:\Program Files\wkhtmltopdf\bin\wkhtmltoimage.exe"
Check system status:
dotnet run --project MarkdownToImageConverter.csproj --check
Usage
MarkdownToImageConverter <markdown-file-path> [wkhtmltoimage-path]
MarkdownToImageConverter --check
Examples
# Check system status
dotnet run --project MarkdownToImageConverter.csproj --check
# Using wkhtmltoimage from PATH
dotnet run --project MarkdownToImageConverter.csproj example.md
# Specifying wkhtmltoimage path
dotnet run --project MarkdownToImageConverter.csproj example.md "C:\Program Files\wkhtmltopdf\bin\wkhtmltoimage.exe"
Input Format
The application looks for HTML sections in markdown files marked with html
code blocks:
# My Document
Some regular markdown content...
## HTML Section
```html
<style>
.my-class {
color: blue;
font-family: Arial;
}
</style>
<div class="my-class">
<h1>Hello World</h1>
<p>This will be converted to an image!</p>
</div>
\```
More markdown content...
Output
- Images are saved in the
images
folder - Each HTML section becomes a separate PNG file
- Files are named:
{markdown-filename}_section_{number}.png
- Example:
sample_section_1.png
,sample_section_2.png
How It Works
- Parse Markdown: Reads the markdown file and extracts all
html
blocks - Process HTML: Creates complete HTML documents with proper structure
- Extract Styles: Separates CSS styles and HTML content
- Generate Images: Uses wkhtmltoimage to render HTML to PNG images
- Save Results: Outputs images to the
images
folder
Dependencies
- Markdig: For markdown processing
- HtmlAgilityPack: For HTML parsing and manipulation
- wkhtmltoimage: External tool for HTML to image conversion
Error Handling
The application handles various error conditions:
- Missing markdown files
- Invalid HTML content
- wkhtmltoimage execution failures
- File system errors
Sample File
A sample.md
file is included that demonstrates the expected input format with working HTML/CSS examples.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- HtmlAgilityPack (>= 1.11.65)
- Markdig (>= 0.37.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.