You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: claude.md
+17-8Lines changed: 17 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
4
4
5
5
## Project Overview
6
6
7
-
Morph is a .NET library that converts Microsoft Word DOCX documents into PNG images. The public API lives in the `WordRender` namespace. The main entry point is `DocumentConverter`, which exposes `ConvertToImages` (file/stream → PNG files) and `ConvertToImageData` (file/stream → byte arrays).
7
+
Morph is a .NET library that converts Microsoft Word DOCX documents or HTML content into PNG images. The DOCX public API lives in the `WordRender` namespace (entry point: `DocumentConverter`). The HTML public API lives in the `HtmlRender` namespace (entry point: `HtmlConverter`). Both expose `ConvertToImages` and `ConvertToImageData`.
The conversion pipeline is **Parse → Render**, split across multiple assemblies:
30
30
31
-
1.**Parsing** (`src/Morph/Parsing/`): `DocumentParser` reads OOXML via DocumentFormat.OpenXml and builds a `ParsedDocument` containing a tree of `DocumentElement` types (defined in `DocumentElements.cs`). Sub-parsers handle shapes, ink, themes, and HTML (AltChunk).
31
+
**Core model** (`src/Morph/`): `ParsedDocument`, `DocumentElement` types (defined in `DocumentElements.cs`), shared rendering base (`RenderContextBase`, `FontCacheLoader`, `FontHelpers`, `TableLayout`), `ConversionOptions`, `ConversionResult`. No heavy dependencies.
32
32
33
-
2.**Rendering** — two interchangeable backends behind an abstract `DocumentConverter` base class:
-**DOCX** (`src/Morph.OpenXml/`): `DocumentParser` reads OOXML via DocumentFormat.OpenXml and builds a `ParsedDocument`. Sub-parsers handle shapes, ink, themes, and HTML (AltChunk).
35
+
-**HTML** (`src/Morph.Html/`): `HtmlParser` converts HTML to `DocumentElement` trees via AngleSharp. `HtmlConverter` abstract base class.
37
36
38
-
Each backend has its own `PageRenderer`, `TextRenderer`, and `RenderContext`.
37
+
**Rendering backends** — each has its own `PageRenderer`, `TextRenderer`, and `RenderContext`:
38
+
-**SkiaSharp** (`src/Morph.Skia/`): rendering engine using SkiaSharp + Svg.Skia
39
+
-**ImageSharp** (`src/Morph.ImageSharp/`): rendering engine using SixLabors.ImageSharp / ImageSharp.Drawing / Fonts
40
+
41
+
**Entry points** (thin wrappers combining a parser with a rendering backend):
42
+
-`src/Morph.OpenXml.Skia/` — `WordRender.Skia.DocumentConverter` (DOCX → PNG via SkiaSharp)
43
+
-`src/Morph.OpenXml.ImageSharp/` — `WordRender.ImageSharp.DocumentConverter` (DOCX → PNG via ImageSharp)
44
+
-`src/Morph.Html.Skia/` — `HtmlRender.Skia.HtmlConverter` (HTML → PNG via SkiaSharp)
45
+
-`src/Morph.Html.ImageSharp/` — `HtmlRender.ImageSharp.HtmlConverter` (HTML → PNG via ImageSharp)
46
+
47
+
The HTML packages have no transitive dependency on `DocumentFormat.OpenXml`.
|**SkiaSharp**|`Morph.Skia`| Mature, includes SVG support |
114
-
|**ImageSharp**|`Morph.ImageSharp`| Fully managed (no native dependencies) |
115
-
116
-
Both backends expose the same API via `WordRender.Skia.DocumentConverter` and `WordRender.ImageSharp.DocumentConverter`.
109
+
| Backend | DOCX Package | HTML Package | Pros |
110
+
|---------|-------------|-------------|------|
111
+
|**SkiaSharp**|`Morph.OpenXml.Skia`|`Morph.Html.Skia`| Mature, includes SVG support |
112
+
|**ImageSharp**|`Morph.OpenXml.ImageSharp`|`Morph.Html.ImageSharp`| Fully managed (no native dependencies) |
117
113
118
114
119
115
## Usage
120
116
117
+
118
+
### DOCX to PNG
119
+
121
120
The examples below use the SkiaSharp backend. To use ImageSharp instead, replace `WordRender.Skia.DocumentConverter` with `WordRender.ImageSharp.DocumentConverter`.
122
121
123
122
@@ -201,6 +200,42 @@ var result = converter.ConvertToImages(
201
200
<!-- endSnippet -->
202
201
203
202
203
+
### HTML to PNG
204
+
205
+
To use ImageSharp instead, replace `HtmlRender.Skia.HtmlConverter` with `HtmlRender.ImageSharp.HtmlConverter`.
0 commit comments