Skip to content

armgit / Filee

Public Imported from GitHub
0

Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.

Merge feat/ebooks

KnifeLemon8e8975d797d7
diff --cc Directory.Packages.props
index 0f934750,d72a7dc2..d2833b98
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@@ -34,14 -34,8 +34,15 @@@
<PackageVersion Include="Unhwp" Version="0.13.0" />
<PackageVersion Include="Markdig" Version="1.4.0" />
<PackageVersion Include="ExcelNumberFormat" Version="1.1.0" />
+ <!-- 5.2+ requires SkiaSharp 4 (see PDFtoImage above); 5.1.1 uses SkiaSharp 3.119 and HarfBuzzSharp 8.3 like Avalonia. -->
+ <PackageVersion Include="Svg.Skia" Version="5.1.1" />
+ <!-- Managed zstd / bzip2 for unpacking downloaded engines (conda packages). -->
+ <PackageVersion Include="SharpCompress" Version="1.0.0" />
+ <PackageVersion Include="ExcelDataReader" Version="3.9.0" />
+ <PackageVersion Include="PdfPig" Version="0.1.16" />
+ <PackageVersion Include="MimeKitLite" Version="4.18.1" />
+ <PackageVersion Include="ACadSharp" Version="3.8.0" />
+ <PackageVersion Include="AngleSharp" Version="1.8.2" />
- <PackageVersion Include="SharpCompress" Version="0.50.4" />
</ItemGroup>
<ItemGroup Label="Tests">
diff --cc THIRD-PARTY-NOTICES.md
index 81eb3428,8dc2ebc4..abadc4d5
--- a/THIRD-PARTY-NOTICES.md
+++ b/THIRD-PARTY-NOTICES.md
@@@ -17,21 -17,13 +17,22 @@@ Each component remains under its own li
| PDFtoImage | MIT | https://github.com/sungaila/PDFtoImage |
| PDFium (bblanchon.PDFium) | BSD-3-Clause / Apache-2.0 | https://pdfium.googlesource.com/pdfium |
| SkiaSharp | MIT | https://github.com/mono/SkiaSharp |
+| Svg.Skia (incl. Svg, ShimSkiaSharp, ExCSS; text shaping in `Filee.Engines/Vector/OutlinedTextPlayback.cs` adapted from it) | MIT | https://github.com/wieslawsoltes/Svg.Skia |
+| HarfBuzzSharp | MIT | https://github.com/mono/SkiaSharp |
- | SharpCompress (zstd decompression for engine downloads) | MIT | https://github.com/adamhathcock/sharpcompress |
++| SharpCompress (zstd decompression for engine downloads; RAR, 7z and TAR comics) | MIT | https://github.com/adamhathcock/sharpcompress |
| Unhwp | MIT | https://github.com/iyulab/unhwp |
| Markdig | BSD-2-Clause | https://github.com/xoofx/markdig |
| ExcelNumberFormat | MIT | https://github.com/andersnm/ExcelNumberFormat |
+| ExcelDataReader | MIT | https://github.com/ExcelDataReader/ExcelDataReader |
+| PdfPig (PDF text, layout and pictures) | Apache-2.0 | https://github.com/UglyToad/PdfPig |
+| MimeKitLite (e-mail / MIME parsing) | MIT | https://github.com/jstedfast/MimeKit |
+| ACadSharp (DWG/DXF reading and writing; includes CSMath and CSUtilities) | MIT, Copyright (c) Albert Domenech | https://github.com/DomCR/ACadSharp |
+ | AngleSharp | MIT | https://github.com/AngleSharp/AngleSharp |
-| SharpCompress | MIT | https://github.com/adamhathcock/sharpcompress |
| pypandoc-hwpx (Pandoc AST mapping and package layout in `Filee.Engines/Hwp/Hwpx`, incl. the `blank.hwpx` reference document) | MIT, Copyright (c) 2024 pypandoc-hwpx Contributors | https://github.com/msjang/pypandoc-hwpx |
| Microsoft.Extensions.* | MIT | https://github.com/dotnet/runtime |
+| cu2qu (fontTools): the cubic-to-quadratic approach followed by `Filee.Engines/Fonts/Cff/CubicToQuadratic.cs` | Apache-2.0, Copyright 2016 Google Inc. | https://github.com/fonttools/fonttools |
+
+Used by the tests only (not redistributed): DocumentFormat.OpenXml (Open XML SDK, MIT, https://github.com/dotnet/Open-XML-SDK) validates the DOCX files Filee writes.
## Engines
@@@ -56,9 -42,7 +57,10 @@@ Downloaded from their official release
| H2Orestart (HWP/HWPX import for LibreOffice) | GPL-3.0 | https://github.com/ebandal/H2Orestart |
| Eclipse Temurin JRE (for H2Orestart) | GPL-2.0 with Classpath Exception | https://adoptium.net |
| Pandoc | GPL-2.0-or-later | https://github.com/jgm/pandoc |
+| Ghostscript (conda-forge build) | AGPL-3.0 | https://www.ghostscript.com, https://github.com/conda-forge/ghostscript-feedstock |
+| Microsoft Visual C++ Redistributable (for Ghostscript, conda-forge `vc14_runtime`) | Microsoft Visual C++ Redistributable license | https://github.com/conda-forge/vc-feedstock |
+| FFmpeg 9.0.2 (gyan.dev "full_build-shared" Windows build; ffmpeg.exe, ffprobe.exe and their libraries, incl. x264, x265, libvpx, LAME, Opus, Vorbis, Theora, OpenCORE AMR) | GPL-3.0-or-later (the build is configured with `--enable-gpl --enable-version3`); FFmpeg itself LGPL-2.1-or-later | https://ffmpeg.org, build: https://www.gyan.dev/ffmpeg/builds/ (source: https://github.com/GyanD/codexffmpeg) |
+ | calibre (ebook-convert) | GPL-3.0 | https://calibre-ebook.com |
These programs run as separate processes. Their source code is available from the linked projects.
diff --cc build/fetch-engines.ps1
index 387646f6,76c77081..b9f7f4ad
--- a/build/fetch-engines.ps1
+++ b/build/fetch-engines.ps1
@@@ -12,10 -12,8 +12,12 @@@
jre/ Eclipse Temurin JRE 21 (GPLv2 + Classpath Exception), used by H2Orestart
rhwp/ rhwp command line (MIT), HWP/HWPX -> PDF
pandoc/ Pandoc (GPL-2.0-or-later, separate program), Markdown/HTML and MD/HTML/ODT/RTF -> HWPX
+ 7zip/ 7-Zip console (7z.exe + 7z.dll, LGPL-2.1 + unRAR restriction, separate program), archives
+ ghostscript/ Ghostscript (AGPL-3.0, separate program) from conda-forge, EPS/PS <-> PDF, with the Microsoft
+ C++ runtime DLLs (vcruntime/) copied next to gswin64c.exe
+ ffmpeg/ FFmpeg (GPL-3.0 build, separate program), video and audio; bin/ffmpeg.exe + bin/ffprobe.exe
+ calibre/ calibre (GPL-3.0, separate program), extracted from the official MSI via an administrative
+ install: ebook-convert for LIT, LRF, PDB, ... and MOBI / AZW3 output
Every download is pinned to a version and verified with SHA-256 (src/Filee.Engines/Infrastructure/engines.json,
shared with the app). Downloads are cached in build/.cache.
@@@ -204,16 -157,20 +206,32 @@@ if ('h2orestart' -in $selected)
}
}
+if ('vcruntime' -in $selected -or 'ghostscript' -in $selected) {
+ Expand-Conda (Get-Engine 'vcruntime') (Join-Path $Destination 'vcruntime')
+}
+
+if ('ghostscript' -in $selected) {
+ $target = Join-Path $Destination 'ghostscript'
+ Expand-Conda (Get-Engine 'ghostscript') $target
+ if (-not (Test-Path (Join-Path $target 'gswin64c.exe'))) { throw 'gswin64c.exe not found in the Ghostscript package.' }
+ # App-local Microsoft C++ runtime next to gswin64c.exe, as EngineInstaller does.
+ Copy-Item (Join-Path $Destination 'vcruntime\*.dll') $target -Force
+}
+
+ if ('calibre' -in $selected) {
+ $msi = Get-Engine 'calibre'
+ $tmp = Join-Path $cache 'calibre-admin'
+ Reset-Folder $tmp
+ Write-Host 'unpack calibre (administrative install, no system changes)'
+ $proc = Start-Process msiexec.exe -ArgumentList @('/a', "`"$msi`"", '/qn', "TARGETDIR=`"$tmp`"") -Wait -PassThru
+ if ($proc.ExitCode -ne 0) { throw "msiexec /a failed with exit code $($proc.ExitCode)." }
+
+ $convert = Get-ChildItem $tmp -Recurse -Filter 'ebook-convert.exe' | Select-Object -First 1
+ if (-not $convert) { throw 'ebook-convert.exe not found after extracting the MSI.' }
+ $target = Join-Path $Destination 'calibre'
+ Reset-Folder $target
+ Get-ChildItem $convert.DirectoryName -Force | Move-Item -Destination $target
+ Remove-Item $tmp -Recurse -Force
+ }
+
Write-Host "Engines ready in $Destination"
diff --cc docs/ENGINES.md
index 9c62c115,91781f51..90f4c887
--- a/docs/ENGINES.md
+++ b/docs/ENGINES.md
@@@ -12,28 -10,16 +12,30 @@@ Filee chooses engines automatically. Se
| PDFium | built in (library) | PDF → images (multi-page TIFF/GIF supported) |
| Unhwp | built in (library) | HWP/HWPX → TXT, Markdown, HTML |
| Markdown (Markdig) | built in (library) | **Markdown → HTML, TXT** (and → PDF / DOCX through the HWPX writer, rhwp or LibreOffice) |
-| Spreadsheets | built in | **XLSX ↔ CSV** (one CSV per sheet) |
-| **HWPX writer** | built in | **DOCX, XLSX, CSV, PPTX, TXT, Markdown, HTML → HWPX** (and with rhwp → PDF and images); ODT, RTF → HWPX with Pandoc |
+| Spreadsheets (ExcelDataReader for XLS) | built in (library) | **XLSX, XLS, ODS, CSV, TSV → XLSX, ODS, CSV, TSV** (one CSV / TSV per sheet) |
+| Office Open XML | built in | **DOCM / DOTX / DOTM ↔ DOCX, XLSM / XLTX ↔ XLSX, PPTM / POTX / PPSX ↔ PPTX** (macros removed for macro-free types) |
+| Fonts | built in | **TTF, OTF, WOFF, WOFF2, EOT ↔ each other**; CFF (PostScript) outlines become TrueType for TTF and EOT |
- | **HWPX writer** | built in | **DOCX (+ DOCM/DOTX/DOTM), XLSX (+ XLSM/XLTX), XLS, ODS, CSV, TSV, PPTX (+ PPTM/POTX/PPSX), PDF, TXT, Markdown → HWPX** (and with rhwp → PDF and images); HTML, ODT, RTF, reStructuredText, LaTeX → HWPX with Pandoc |
++| **HWPX writer** | built in | **DOCX (+ DOCM/DOTX/DOTM), XLSX (+ XLSM/XLTX), XLS, ODS, CSV, TSV, PPTX (+ PPTM/POTX/PPSX), PDF, HTML, EPUB, MOBI/AZW3, FB2, HWPX, TXT, Markdown → HWPX** (and with rhwp → PDF and images); ODT, RTF, reStructuredText, LaTeX → HWPX with Pandoc |
+| **DOCX writer** | built in | **Markdown, TXT, XLSX, CSV, PPTX (+ variants), PDF → DOCX** |
+| PDF text | built in (PdfPig) | **PDF → TXT** (reading order, also two columns; no OCR) |
+| E-mail | built in (MimeKit) | **EML → HTML** (headers + body, inline pictures), **TXT**, **ZIP** (the attachments) |
+ | **E-books** | built in | **EPUB, MOBI/AZW/AZW3/PRC, FB2, HTMLZ, TXTZ → EPUB, HWPX (→ PDF), TXT, HTML, Markdown, FB2, HTMLZ, TXTZ**; HTML, Markdown, TXT, DOCX → EPUB/FB2/HTMLZ/TXTZ; HTML → TXT; comics CBZ/CBR/CB7/CBT/CBC → PDF, EPUB, CBZ; PDF → CBZ; AZW4 → PDF |
+| CAD (ACadSharp + built-in renderer) | built in (library) | **DWG ↔ DXF**; DWG/DXF → **PDF** (vector), **SVG**, PNG, JPG, WEBP, TIFF, BMP, GIF, ICO, AVIF |
| rhwp | bundled with the installer (`engines/rhwp`) | HWP/HWPX → PDF, **HWP → HWPX, HWPX → HWP** |
-| LibreOffice + H2Orestart + Java | **optional download** (~420 MB, 1.3 GB on disk) | older and rare formats only: DOC, XLS, PPT, RTF and OpenDocument → PDF and to each other, output as DOCX/ODT/ODS; HWP/HWPX → DOCX/ODT |
-| Pandoc | **optional download** (~42 MB, 240 MB on disk) | Markdown ↔ DOCX/ODT/RTF, DOCX/ODT/HTML/RTF → Markdown, HTML ↔ DOCX/ODT |
+| Archives (7-Zip) | bundled with the installer (`engines/7zip`, ~2.5 MB) + built-in readers | ZIP, 7Z, RAR, TAR (+ GZ/BZ2/XZ/Z/7Z/LZ), CAB, ISO, DMG, … **→ folder, ZIP, 7Z, TAR, TAR.GZ/BZ2/XZ**; ALZ, EGG, lzip read in-process; "Compress into one archive" for any files |
+| LibreOffice + H2Orestart + Java | **optional download** (~420 MB, 1.3 GB on disk) | older and rare formats only: DOC, XLS, PPT, RTF and OpenDocument → PDF and to each other, output as DOCX/ODT/ODS/ODP; HWP/HWPX → DOCX/ODT; read-only formats (see below) → PDF and their kind's editable formats |
+| Pandoc | **optional download** (~42 MB, 240 MB on disk) | Markdown ↔ DOCX/ODT/RTF, DOCX/ODT/HTML/RTF → Markdown, HTML ↔ DOCX/ODT, reStructuredText and LaTeX ↔ Markdown/HTML/DOCX/ODT (and → RTF, EPUB, TXT) |
+| Ghostscript | **optional download** (~20 MB, 31 MB on disk) | EPS/PS → PDF, PDF → EPS/PS, PostScript-based AI → PDF (images through PDF and PDFium) |
+| FFmpeg | **optional download** (~100 MB, 272 MB on disk) | **all video and audio**: video ↔ video, video → animated GIF or a still frame, audio extraction, audio ↔ audio, GIF → MP4/WEBM/MOV |
+ | Calibre | **optional download** (~216 MB, 660 MB on disk) | rare e-book formats: LIT, LRF, CHM, PDB, PML, RB, SNB, TCR, OEB → EPUB; EPUB → MOBI, AZW3, LIT, LRF, PDB, PML, RB, SNB, TCR |
-DOCX, XLSX and PPTX → PDF need neither Microsoft Office nor LibreOffice: they are read in-process, written as HWPX
-and rendered by rhwp. LibreOffice's cost is set so the built-in route always wins where one exists.
+DOCX, XLSX, XLS, ODS and PPTX → PDF need neither Microsoft Office nor LibreOffice: they are read in-process, written as HWPX
+and rendered by rhwp. Anything the built-in readers understand (including PDF) is written as DOCX by the DOCX writer.
+LibreOffice's and Pandoc's costs are set so the built-in route always wins where one exists.
+
+All built-in document readers are registered in one place, `Hwp/Hwpx/DocumentReaders.cs` (format id → reader, and
+which formats need Pandoc). The HWPX writer and the DOCX writer take their input formats from it: adding a reader
+there is one line and makes both writers (and every route through them) accept the format.
Filee never uses software installed on the system (Microsoft Office, an installed LibreOffice, programs on `PATH`):
every engine is built in, bundled or downloaded into Filee's own folder, so a conversion behaves the same on every
@@@ -51,12 -37,9 +53,13 @@@ they can be installed or removed later
engine folder only when complete. Redirects to mirrors (even plain HTTP) are followed, because the hash decides.
- Engines go to `%LOCALAPPDATA%\Filee\engines`: outside the app folder, so updates keep them, and inside Filee's
install root, so uninstalling removes them.
- - LibreOffice comes as an MSI and is unpacked with an administrative install (`msiexec /a`): files only, no
- registry entries, no admin rights. Help, gallery and most dictionaries are removed afterwards (~500 MB).
+ - LibreOffice and calibre come as MSIs and are unpacked with an administrative install (`msiexec /a`): files only,
+ no registry entries, no admin rights. LibreOffice's help, gallery and most dictionaries are removed afterwards
+ (~500 MB).
+- Ghostscript comes from conda-forge (Artifex publishes only an NSIS installer): a `.conda` package is a zip with a
+ zstd tarball, of which only `Library/bin` is unpacked (SharpCompress; `fetch-engines.ps1` uses Windows' `tar.exe`).
+ Its fonts and resources are compiled into `gsdll64.dll`. The Microsoft C++ runtime it was built against
+ (`vcruntime` component) is copied next to `gswin64c.exe`, so it runs on PCs without the VC++ Redistributable.
To bump a version, change `url`, `sha256` and `size` in engines.json together, run
`pwsh build/fetch-engines.ps1`, test, and update `THIRD-PARTY-NOTICES.md`. When the LibreOffice team retires a
@@@ -115,11 -77,16 +118,18 @@@ Readers turn the source into a small do
- **TXT** needs no reader (one paragraph per line; UTF-8, UTF-16 or the Korean code page CP949).
- **Markdown** is parsed with Markdig (`MarkdownReader.cs`): headings, emphasis, code, lists (1. / a. / i. with
start numbers), task lists, quotes, tables with spans, links, images, footnotes and math. No Pandoc needed.
+- **PDF** is read with PdfPig (see *PDF reader* below); DOCM / DOTX / DOTM, XLSM / XLTX and PPTM / POTX / PPSX
+ are read like DOCX, XLSX and PPTX.
- - **HTML, ODT, RTF, reStructuredText, LaTeX** are parsed by Pandoc into its JSON AST (`PandocAstReader.cs`, following
+ - **HTML** is parsed with AngleSharp (`HtmlReader.cs`, `HtmlCss.cs`): headings, paragraphs, bold / italic /
+ underline / strike / sub / sup / code / mark, the basic inline CSS (colour, background, font weight, style and
+ size, text-align, text-indent, page breaks) and simple `tag` / `.class` rules of style sheets, nested lists with
+ start numbers and types, tables with spans / header rows / borders, pictures (local files and data: URIs; remote
+ pictures are skipped), links and anchors, quotes, `pre`, `hr` and figures. Scripts, styles, forms and `nav` are
+ skipped. The encoding comes from the BOM, the XML declaration or `<meta charset>`, else UTF-8 or the system
+ code page. No Pandoc needed.
+ - **ODT, RTF** are parsed by Pandoc into its JSON AST (`PandocAstReader.cs`, following
[pypandoc-hwpx](https://github.com/msjang/pypandoc-hwpx)).
- - Markdown and Pandoc keep structure only, so page setup comes from the built-in template (A4).
+ - Markdown, HTML and Pandoc keep structure only, so page setup comes from the built-in template (A4).
Element order and attribute values follow files saved by 한글 where the schema and 한글 disagree, for example:
@@@ -135,214 -102,45 +145,253 @@@ text) and LibreOffice + H2Orestart (ope
Not converted: Word charts, SmartArt, equations (kept as text), free-form shapes, tracked changes and comments.
+## Spreadsheets
+
+`SpreadsheetConverter` (engine id `spreadsheet`) converts between XLSX, XLS (also `.xlt`), ODS, CSV and TSV (also
+`.tab`) in-process; every format goes through one in-memory workbook (`Office/Sheets/Workbook.cs`) whose cells keep
+the text the spreadsheet shows, the value behind it and its Excel number format.
+
+| Format | Read | Written |
+|---|---|---|
+| XLSX | own reader: values, number formats, fonts, fills, borders, alignment, merges, widths, heights, hidden rows / columns / sheets, frozen rows | every sheet, numbers and dates as numbers with their formats, booleans, styles, merges, widths, heights, hidden rows / columns, frozen rows |
+| XLS (Excel 97–2003, also Excel 5/95) | ExcelDataReader (MIT): values, number formats, merges, horizontal / vertical alignment; widths, heights and hidden rows / columns from the BIFF records (`XlsLayout.cs`) | no (LibreOffice) |
+| ODS | own reader (`content.xml`, `styles.xml`, `settings.xml`): repeated rows / columns (the empty repeats up to the end of the sheet are skipped), spans, every value type, the text Calc shows (`text:p`), data styles as Excel codes, cell styles, widths, heights, hidden rows / columns / sheets, frozen and header rows | every sheet, typed cells (float, percentage, currency, date, time, boolean) with data styles and the shown text, styles, merges, widths, heights, hidden rows / columns, frozen rows |
+| CSV / TSV | delimiter (CSV: comma, semicolon or tab; TSV: tab) and encoding (UTF-8 / UTF-16 with BOM, else CP949) | UTF-8 with BOM, CRLF, one file per sheet |
+
+- Number formats: Excel codes and OpenDocument data styles are converted both ways (`OdsNumberStyles.cs`) for
+ digits, decimals, grouping, thousands scaling, percent, scientific, currency symbols, literal text, colours,
+ positive / negative / zero sections, dates, times and durations. Codes with conditions (`[>100]`), fractions or
+ text between digits are written as plain numbers (General).
+- Column widths use Excel's unit (a digit of Calibri 11 = 7 px); in ODS a character is 5.25 pt. LibreOffice
+ measures with its own fonts, so a width can differ by up to a fifth after LibreOffice opens the file.
+- XLS cells keep the default font, fill and borders (ExcelDataReader does not expose them); XLS output still
+ needs LibreOffice. Password-protected XLS and ODS files stop with a clear message.
+- Not converted: formulas (their cached results are kept), charts, pictures, comments, conditional formatting,
+ data validation, print areas and page breaks.
+
+## Fonts
+
+Fonts are converted in-process (`Filee.Engines/Fonts`); zlib and Brotli come with .NET. The input format is
+recognised by content, so a mislabelled file still converts.
+
+- **WOFF 1.0**: every table zlib-compressed (stored as-is when that isn't smaller). Lossless both ways.
+- **WOFF2**: one Brotli stream at the highest quality with the glyf/loca transform and, where it applies, the hmtx
+ transform, so files come out the size of Google's reference encoder's. Reading handles both transforms, the
+ overlap bitmap, untransformed tables and the first font of a WOFF2 collection. Like other encoders, Filee drops
+ the DSIG signature and sets bit 11 of head.flags. Brotli is slow on big fonts (about 10 s per MB, so about a
+ minute for a 4.6 MB CJK font); the job shows progress and can be cancelled.
+- **EOT**: written as version 0x00020001 (names and OS/2 fields in the header, no MicroType Express compression, no
+ XOR obfuscation, no URL restriction). Uncompressed EOT files are read (XOR-obfuscated ones too); MTX-compressed
+ ones fail with a clear message.
+- **TTF → OTF** keeps the TrueType outlines: TrueType-flavoured OpenType is valid OpenType and what systems and
+ browsers expect; cubic outlines would gain nothing.
+- **OTF with CFF outlines → TTF** (and → EOT, because Internet Explorer renders only TrueType outlines in EOT)
+ converts the glyphs: Type 2 charstrings with subroutines, flex, seac accents and CID-keyed fonts are drawn, curves
+ are approximated with quadratic splines within 1/1000 em (the approach of fontTools' cu2qu) and contours are
+ reversed to TrueType's direction. glyf, loca, maxp 1.0 and post (format 2 with the CFF glyph names, format 3 for
+ CID fonts) are built; head, hhea, hmtx and, from VORG, vmtx are updated; CFF, VORG and DSIG are dropped; every
+ other table (cmap, name, OS/2, GSUB, GPOS, kern, ...) is kept. PostScript hints are not converted: the font gets a
+ gasp table (smoothing at every size) and a prep that switches on dropout control instead.
+- Not supported: CFF2 (variable) outlines to TTF or EOT (to WOFF, WOFF2 and OTF they convert), writing font
+ collections, and WOFF/WOFF2 extended metadata (dropped).
+
+`tests/Filee.Engines.Tests/FontTests.cs` checks every conversion with small OFL fonts in
+`tests/Filee.Engines.Tests/Fonts` (see `OFL.txt` there): round trips keep every table byte for byte, a WOFF2 made
+by Google's encoder decodes to the source font, and converted CFF glyphs are compared with the originals in Skia.
+
+## DOCX writer
+
+The counterpart of the HWPX writer: `Hwp/Hwpx/Docx/DocxWriter*.cs` writes WordprocessingML by hand from the same
+document model, so every reader in `DocumentReaders` can produce an editable Word file without Word, LibreOffice or
+Pandoc. It writes:
+
+- sections with page size, orientation, margins (header and footer distances), columns, page number restarts;
+ columns that change mid-page become continuous section breaks, as Word does it;
+- headers and footers (odd/even pages, "different first page") with PAGE / NUMPAGES fields; a section without its
+ own header gets an empty one, since Word would otherwise repeat the previous section's;
+- paragraphs: alignment, indents (first line / hanging), spacing, line spacing (the model's percent of the font
+ size is converted back to Word's multiple, the inverse of DocxReader), keep with next / keep lines / widow
+ control, tab stops with leaders, page and column breaks;
+- runs: Latin and East Asian fonts, size, bold, italic, underline, strike, colour, highlight (Word's named colours)
+ or shading, super/subscript, letter spacing;
+- headings as Word's built-in "heading 1".."heading 9" styles (outline levels, so the navigation pane and tables of
+ contents work), lists as real numbering definitions (1., a., 가., ①, bullets, start numbers, nine levels);
+- tables with column widths, horizontal and vertical merges, borders, fills, cell alignment, row heights and
+ repeated header rows;
+- pictures inline and floating (anchored to page, margin, column or paragraph, with wrapping), text boxes and
+ rectangles / rounded rectangles / ellipses / lines as Word 2010 shapes (wps) with solid or gradient fills and
+ outlines, hyperlinks (web and to bookmarks), bookmarks, footnotes and endnotes.
+
+Parts, relationships and content types are written per part (pictures and links in headers and notes are related
+from their own part), children in schema order. The tests validate every file with the Open XML SDK schema
+validator, read it back with DocxReader (DOCX → model → DOCX → model keeps the layout) and convert it with
+LibreOffice as an independent reader, see `tests/Filee.Engines.Tests/DocxWriterTests.cs`.
+
+Its edges cost 8, less than Pandoc's and LibreOffice's direct conversions, so Markdown → DOCX, PDF → DOCX, ... use
+it. DOCX → DOCX is no edge; the Word variants are the Office Open XML engine's job.
+
+## PDF reader
+
+`Pdf/PdfDocumentReader*.cs` reads PDFs with PdfPig (Apache-2.0) into the document model, for PDF → DOCX, HWPX and
+(with `PdfTextConverter`) TXT:
+
+- words with their positions, fonts, sizes and colours → lines → paragraphs: a line continues the paragraph above
+ when it follows at about one line pitch, unless it starts with a bullet or number, is indented as a first line,
+ or the previous line ended although the next word would have fitted; hyphenated line ends are joined, and no
+ space is added between Chinese or Japanese lines;
+- reading order: gutters between columns are found where no narrow paragraph crosses; paragraphs that span the
+ columns (titles, figures, closing text) split the page into bands, read column by column;
+- headings from font sizes (short paragraphs clearly larger than the body text, the largest size is level 1), bold
+ and italic from the fonts, colours, links from link annotations, alignment, indents, spacing and line pitch;
+- pictures: JPEG streams are kept as they are, others are decoded to PNG, and what PdfPig cannot decode is cut out
+ of the rendered page; a picture covering the page behind text (the scan under an OCR layer) is skipped;
+- page size per page and margins shared by the document; running headers and footers that repeat on most pages
+ (and bare page numbers) are left out;
+- a page without text (a scan, a page of drawings, a turned page) becomes the rendered page (PDFium, 150 dpi JPEG)
+ as a picture behind the text of an empty page, so nothing is lost; there is no OCR. PDF → TXT includes the
+ invisible OCR text layer of scanned PDFs that have one.
+
+Password-protected PDFs fail with a clear message. Not converted: tables (their cells come out as paragraphs in
+reading order), vector drawings on text pages, form fields and annotations other than links.
+
+## Office Open XML variants
+
+`Office/OoxmlConverter.cs` converts between the variants of a family (Word, Excel, PowerPoint) by copying the
+package with the main part's content type rewritten. Going to a macro-free type also removes the VBA project, its
+signatures and data, Word's key map customisations and Excel 4.0 macro sheets (with their sheet entries), and every
+relationship and content type entry pointing to them. The built-in readers take the variants directly (DOCM → HWPX,
+XLSM → CSV, PPSX → DOCX ...).
+
+## E-mail
+
+`Email/EmlConverter.cs` reads .eml files with MimeKitLite (MIT), which decodes quoted-printable and base64, encoded
+headers (RFC 2047 / 2231) and charsets including EUC-KR / CP949 and ISO-2022-KR; raw 8-bit header text that is not
+UTF-8 is read as CP949, as older Korean mail programs wrote it.
+
+- **EML → HTML**: a standalone page with From / To / Cc / Date / Subject / Attachments and the HTML body (its style
+ sheets kept, scripts removed) or the text body; pictures sent inline (`cid:`) become data URIs.
+- **EML → TXT**: the same headers and the text body (or the HTML body as text).
+- **EML → ZIP**: the attachments (attached messages as .eml) with safe, unique file names.
+
+## CAD drawings (DWG, DXF)
+
+Built in, no AutoCAD or ODA software (`Filee.Engines/Cad`). [ACadSharp](https://github.com/DomCR/ACadSharp) reads
+and writes the files; Filee's own renderer draws them with SkiaSharp (one drawing routine for PDF, SVG and images).
+
+- **Reading**: DWG from R14 (AC1014) to the AutoCAD 2018 format (AC1032, still current in AutoCAD 2026); DXF R12 to
+ 2018, ASCII and binary. DWG R13 and older fail with "version not supported". Korean AutoCAD writes pre-2007 DXF with
+ the code page name `ANSI_949`, which ACadSharp 3.8 does not map; Filee rewrites that header in memory so the text
+ is decoded as CP949 (`CadFile.OpenDxf`, covered by a test that fails once ACadSharp handles it).
+- **Writing** (DWG ↔ DXF): always **AutoCAD 2018 (AC1032)** — the current DWG format (AutoCAD 2018 and later, DWG
+ TrueView, BricsCAD, ODA tools); 2018 DXF stores text as UTF-8. ACadSharp's DWG writer is younger than its reader
+ and its DXF writer, so DXF is the safer format to hand on. Objects ACadSharp does not model (proxy and AEC objects,
+ some 3D and underlay data) are not written; degenerate dimensions it cannot measure are left out of DWG output
+ instead of failing the file.
+- **What is drawn**: model space seen from the top (Z is dropped). If model space has nothing visible, the active
+ layout (paper space) is drawn instead; viewports inside it are not followed. The page is fitted to the extents of
+ what is actually drawn — the header's EXTMIN/EXTMAX are ignored, so drawings far from the origin still fill it.
+ - PDF: an ISO A3 sheet (A4 or Letter when the preset asks for it), landscape when the drawing is wider than tall,
+ 10 mm margins (or the preset's margin). Vector paths, text as text with embedded fonts.
+ - SVG: the drawing's aspect ratio with a 420 mm (A3) long edge at 96 px/inch, white background, text as `<text>`.
+ - Images: the same page rendered at the preset's render resolution (150 dpi → 2480 px on the long edge, at most
+ 12 000 px / 80 MP), then the preset's image options (resize, grayscale, quality, DPI) as for other images.
+- **Entities**: LINE, XLINE/RAY (clipped to the page), LWPOLYLINE and POLYLINE (bulges, constant and tapered widths,
+ spline-fit and 3D), CIRCLE, ARC, ELLIPSE (also partial), SPLINE (NURBS from control points, knots and weights, or
+ a smooth curve through fit points), TEXT, ATTRIB and MTEXT (justification, rotation, width factor, oblique,
+ mirroring; MTEXT word wrap, height/colour/font/width codes, stacked fractions shown as `1/2`, `%%d` `%%c` `%%p`,
+ `\U+` and `\M+` escapes), INSERT (base point, scale, rotation, MINSERT arrays, nesting, attributes), DIMENSION and
+ TABLE (their anonymous block), LEADER, MULTILEADER (lines, arrows, text or block content), HATCH, SOLID/TRACE,
+ 3DFACE edges, POINT, MLINE, polyface and polygon meshes (edges).
+- **Hatches**: solid fills, gradients as a linear gradient, patterns as their real pattern lines clipped to the
+ boundary; a pattern too dense to draw (over 20 000 segments) becomes a light tint of its colour.
+- **Colours and lines**: ACI index table and true colour, BYLAYER / BYBLOCK (inside blocks, entities on layer "0"
+ follow the insert's layer). White and near-white (ACI 7, which AutoCAD shows white on black) draw black on the white
+ page. Line weights are plotted in millimetres ("Default" as a thin 0.18 mm line); line types become dash patterns
+ scaled by LTSCALE, the entity's scale and the block scale (shapes and text inside complex line types are omitted).
+- **Layers**: off, frozen and non-plotting layers (including Defpoints) are not drawn, like a plot. A frozen layer
+ hides a whole block reference; an OFF one only its layer-0 contents.
+- **Fonts**: drawings name SHX fonts, which are not available, so text uses the text style's TrueType font when it is
+ installed (arial.ttf, malgun.ttf ...) and otherwise a sans-serif face (Noto Sans, Arial, Liberation Sans ...).
+ Characters the font lacks fall back per character to a CJK font (Noto Sans KR/CJK, Malgun Gothic, Apple SD Gothic
+ Neo, ...). These come from the fonts SkiaSharp finds on the system; without any, SkiaSharp's default typeface is
+ used and the geometry is unaffected.
+- **Not drawn** (counted per type in the log): 3DSOLID, REGION and BODY (ACIS), IMAGE, OLE objects, PDF/DWF/DGN
+ underlays, WIPEOUT (its masking is not applied), SHAPE, TOLERANCE, proxy entities. MTEXT columns, tabs, underline
+ and overline are ignored.
+- **Limits**: 1 000 000 drawn primitives, block nesting depth 16, 10 000 MINSERT cells, 2 000 000 hatch pattern
+ segments in total; beyond that the drawing is cut short with a warning in the log. Damaged or truncated files fail
+ with "The file is not a valid DWG/DXF drawing or is damaged: …".
+
+## HWPX reader
+
+`Hwp/Hwpx/HwpxReader*.cs` is the inverse of the writer: it reads an HWPX package into the same document model, so
+HWPX (and HWP, which rhwp turns into HWPX first) can be written as DOCX, HTML or EPUB without Hancom Office or
+LibreOffice. It reads files saved by 한글, by rhwp's `export-hwpx` and by Filee itself:
+
+- elements are matched by local name (any prefix or namespace version); `hp:switch` takes the `hp:case` for
+ HwpUnitChar / 2016 paragraphs, else `hp:default`, whose lengths 한글 doubles (as are margins and tab stops
+ outside a switch in older files); every `…IDRef` is resolved through `header.xml`;
+- sections in spine order with page size (`landscape="NARROWLY"` turns the portrait sheet), margins, gutter,
+ columns (also changing mid-section), hidden first header/footer, start page (`startNum`, `hp:newNum`);
+- headers and footers (both / odd / even pages) with page numbers and counts; an automatic page number
+ (`hp:pageNum`, e.g. "- 1 -" at the bottom centre) becomes a footer or header paragraph;
+- paragraph shapes (alignment, indents with 한글's hanging-indent convention, spacing, line spacing kinds, tab stops,
+ keep options, page break before) and complete character shapes (fonts per language, size, bold/italic,
+ underline, strikeout, colour, shade, highlighter `hp:markpen`, super/subscript, letter spacing);
+- outline paragraphs (개요) as headings, numbered with the section's outline numbering when it shows numbers;
+ numberings and bullets as lists; tabs, line breaks, non-breaking/fixed-width spaces, soft hyphens; tracked
+ deletions are left out;
+- hyperlinks (HYPERLINK fields, also across paragraphs; `?name` = bookmark), bookmarks, other fields as their
+ text, footnotes and endnotes (without 한글's number), equations as their script text;
+- tables with spans, column widths, row heights, header rows, borders and fills (`borderFill`), cell padding,
+ vertical alignment, captions and nested tables; a table splits the paragraph that holds it;
+- pictures from `BinData` (inline, or floating with `hp:pos` offsets, alignment and wrapping), rectangles,
+ ellipses and lines with outline and solid / gradient fill, text boxes (`hp:drawText`), groups.
+
+Not kept (the model has no place for them; skipped and counted by the `Read(path, media, skipped)` overload):
+OLE objects, charts, video, form controls, text art (its text is kept), arcs / polygons / curves without text,
+master pages, memos, character ratio, relative size and offset, paragraph borders, picture cropping and rotation.
+Password-protected (encrypted) HWPX and DRM-wrapped files stop with a clear error.
+
+ ## E-books
+
+ The built-in e-book engine (`src/Filee.Engines/Ebooks`) reads books into the same document model as the HWPX
+ writer, so every e-book also reaches HWPX, PDF and images. The document model is written back out by
+ `XhtmlWriter` (EPUB chapters, HTMLZ, single-page HTML), `PlainTextWriter`, `MarkdownWriter` and `Fb2Writer`.
+
+ - **EPUB 2 / 3**: container.xml → OPF → spine; each chapter is read by the HTML reader and starts a new page, links
+ between chapters become links to bookmarks, pictures come from the package, title / authors / language / cover
+ from the metadata.
+ - **EPUB output** is EPUB 3 with an NCX for older readers: `mimetype` first and stored, a navigation document from
+ the headings, chapters split at level-1 headings and page breaks, one style sheet, pictures in formats every
+ reader shows (others become JPEG / PNG), a cover page for covers the content does not show.
+ - **MOBI / AZW / AZW3 / PRC** (`Ebooks/Mobi`, written from the MobileRead wiki's format description): PalmDB
+ records, MOBI header and EXTH metadata, PalmDOC (LZ77) and HUFF/CDIC compression, MOBI 6 `filepos` links and
+ `recindex` pictures, KF8 text rebuilt from the skeleton and fragment indexes with `kindle:pos` / `kindle:embed` /
+ `kindle:flow` references resolved, and plain PalmDOC (TEXtREAd) books. **AZW4** (Print Replica) gives back its PDF.
+ - **FB2**: nested sections become headings, poems / epigraphs / citations / tables are kept, note links become
+ footnotes, pictures come from the base64 binaries; the XML declaration's encoding (often windows-1251) is used.
+ FB2 output nests sections by heading level.
+ - **HTMLZ / TXTZ** (calibre's zipped formats) are read and written, with their `metadata.opf`.
+ - **Comics**: CBZ, CBR, CB7, CBT and CBC (a ZIP of CBZ files) are opened with SharpCompress; pages are sorted
+ naturally ("page2" before "page10"). → PDF has one page per picture sized like the picture (JPEGs are embedded
+ as they are), → EPUB is fixed-layout, → CBZ repacks. PDF → CBZ renders the pages with PDFium at the preset DPI.
+ - Books with DRM (Adobe, Apple, Kindle) are refused with a clear message; Filee does not remove DRM. KFX and
+ Topaz books are recognised and refused too.
+
+ ## Calibre
+
+ calibre's `ebook-convert` (GPL-3.0) is an optional download for the formats Filee does not read or write itself:
+ LIT, LRF, CHM, PDB, PML, RB, SNB, TCR and OEB → EPUB, and EPUB → MOBI, AZW3, LIT, LRF, PDB, PML, RB, SNB and TCR.
+ EPUB is the hub, so for example FB2 → AZW3 is FB2 → EPUB (built in) → AZW3 (calibre). Its edges cost 20, so
+ built-in routes always win where they exist.
+
+ - The pinned `calibre-64bit-<version>.msi` from download.calibre-ebook.com is unpacked like LibreOffice; the folder
+ with `ebook-convert.exe` becomes `engines/calibre`.
+ - Each run gets its own configuration, cache and temp folders in the job's work directory
+ (`CALIBRE_CONFIG_DIRECTORY`, ...), so a calibre the user installed is never read or changed; messages are
+ English (`CALIBRE_OVERRIDE_LANG`) and progress comes from its "34% ..." lines.
+
## HWP ↔ HWPX
rhwp converts between the two 한글 formats without Hancom Office (`export-hwpx` and `convert`). Anything → HWP goes
diff --cc src/Filee.App/Assets/i18n/en.json
index 1bbbc447,9119662c..c9a773ae
--- a/src/Filee.App/Assets/i18n/en.json
+++ b/src/Filee.App/Assets/i18n/en.json
@@@ -315,18 -237,12 +315,20 @@@
"engines.optional_description": "Large engines are only downloaded when you want them. They are kept when Filee updates and removed when you uninstall it.",
"engines.all_title": "All engines",
"engines.package.libreoffice.name": "LibreOffice (older and rare formats)",
- "engines.package.libreoffice.description": "Only needed for older and less common formats: DOC, XLS, PPT and OpenDocument files, conversions to DOCX, ODT and ODS, and HWP → DOCX (includes the H2Orestart filter and Java). DOCX, XLSX, PPTX and CSV convert without it.",
- "engines.package.pandoc.name": "Pandoc (HTML and Markdown ↔ Word)",
- "engines.package.pandoc.description": "Markdown ↔ DOCX, ODT and RTF, and ODT and RTF → HWPX. Markdown and HTML → PDF and HWPX, Markdown → HTML and TXT, and DOCX → HWPX work without it.",
+ "engines.package.libreoffice.description": "Only needed for older and less common formats: DOC, XLS, PPT and OpenDocument files, WordPerfect, Works, Apple Pages, Numbers and Keynote, Publisher, CorelDRAW and Visio, conversions to ODT, ODS and ODP, and HWP → DOCX (includes the H2Orestart filter and Java). DOCX, XLSX, PPTX, CSV and PDF convert without it.",
+ "engines.package.pandoc.name": "Pandoc (Markdown, HTML, LaTeX ↔ Word)",
+ "engines.package.pandoc.description": "DOCX, ODT and RTF → Markdown, reStructuredText and LaTeX ↔ Markdown, HTML and DOCX, and HTML, ODT, RTF, reStructuredText and LaTeX → HWPX. Markdown → PDF, DOCX, HWPX, HTML and TXT work without it.",
+ "engines.package.ghostscript.name": "Ghostscript (EPS and PostScript)",
+ "engines.package.ghostscript.description": "EPS, PS and older Illustrator files → PDF, PNG and other images, and PDF or SVG → EPS/PS. SVG and AI files saved with PDF compatibility convert without it.",
+ "engines.package.ffmpeg.name": "FFmpeg (video and audio)",
+ "engines.package.ffmpeg.description": "Video ↔ video (MP4, MOV, MKV, WEBM, AVI, WMV and more), video → animated GIF or a still image, sound from videos (→ MP3, M4A, WAV …), audio ↔ audio (MP3, M4A, FLAC, WAV, OGG, OPUS and more) and GIF → MP4, WEBM, MOV. Only needed for video and audio.",
+ "engines.package.calibre.name": "Calibre (Kindle and rare e-book formats)",
+ "engines.package.calibre.description": "Saves as MOBI and AZW3 for Kindle, and converts rare e-book formats: LIT, LRF, PDB, PML, RB, SNB and TCR, plus CHM and OEB input. EPUB, MOBI, AZW3, FB2 and comics (CBZ, CBR) are read without it.",
"engines.package.size": "Download {0} · {1} on disk",
+ "engines.progress_detail": "{0} of {1} · {2}/s · {3}",
+ "engines.eta.estimating": "estimating time left…",
+ "engines.eta.seconds": "{0} s left",
+ "engines.eta.minutes": "{0} min left",
"engines.install": "Install",
"engines.cancel": "Cancel",
"engines.remove": "Remove",
diff --cc src/Filee.App/Assets/i18n/ko.json
index efff3262,363d5e4b..c0cd6bb4
--- a/src/Filee.App/Assets/i18n/ko.json
+++ b/src/Filee.App/Assets/i18n/ko.json
@@@ -315,18 -237,12 +315,20 @@@
"engines.optional_description": "용량이 큰 엔진은 원할 때만 내려받습니다. Filee를 업데이트해도 유지되고, 제거하면 함께 지워집니다.",
"engines.all_title": "전체 엔진",
"engines.package.libreoffice.name": "LibreOffice (오래되었거나 드문 형식)",
- "engines.package.libreoffice.description": "오래되었거나 흔하지 않은 형식에만 필요해요: DOC·XLS·PPT·OpenDocument 파일, DOCX·ODT·ODS로 변환, HWP → DOCX (H2Orestart 필터와 Java 포함). DOCX·XLSX·PPTX·CSV는 없어도 변환돼요.",
- "engines.package.pandoc.name": "Pandoc (HTML·마크다운 ↔ 워드)",
- "engines.package.pandoc.description": "마크다운 ↔ DOCX·ODT·RTF 변환과 ODT·RTF → HWPX 변환을 추가합니다. 마크다운·HTML → PDF·HWPX, 마크다운 → HTML·TXT, DOCX → HWPX는 없어도 됩니다.",
+ "engines.package.libreoffice.description": "오래되었거나 흔하지 않은 형식에만 필요해요: DOC·XLS·PPT·OpenDocument 파일, 워드퍼펙트·Works, Apple Pages·Numbers·Keynote, Publisher·CorelDRAW·Visio, ODT·ODS·ODP로 변환, HWP → DOCX (H2Orestart 필터와 Java 포함). DOCX·XLSX·PPTX·CSV·PDF는 없어도 변환돼요.",
+ "engines.package.pandoc.name": "Pandoc (마크다운·HTML·LaTeX ↔ 워드)",
+ "engines.package.pandoc.description": "DOCX·ODT·RTF → 마크다운, reStructuredText·LaTeX ↔ 마크다운·HTML·DOCX, HTML·ODT·RTF·reStructuredText·LaTeX → HWPX 변환을 추가해요. 마크다운 → PDF·DOCX·HWPX·HTML·TXT는 없어도 돼요.",
+ "engines.package.ghostscript.name": "Ghostscript (EPS·PostScript)",
+ "engines.package.ghostscript.description": "EPS·PS 파일과 예전 일러스트레이터 파일을 PDF·PNG 등 이미지로, PDF·SVG를 EPS·PS로 변환해요. SVG와 PDF 호환으로 저장한 AI 파일은 없어도 변환돼요.",
+ "engines.package.ffmpeg.name": "FFmpeg (동영상·오디오)",
+ "engines.package.ffmpeg.description": "동영상 ↔ 동영상(MP4·MOV·MKV·WEBM·AVI·WMV 등), 동영상 → 움직이는 GIF·정지 이미지, 동영상에서 소리 추출(→ MP3·M4A·WAV 등), 오디오 ↔ 오디오(MP3·M4A·FLAC·WAV·OGG·OPUS 등), GIF → MP4·WEBM·MOV 변환을 추가해요. 동영상과 오디오에만 필요해요.",
+ "engines.package.calibre.name": "Calibre (킨들과 드문 전자책 형식)",
+ "engines.package.calibre.description": "킨들용 MOBI·AZW3로 저장하고, 드문 전자책 형식(LIT·LRF·PDB·PML·RB·SNB·TCR, CHM·OEB 읽기)을 변환해요. EPUB·MOBI·AZW3·FB2와 만화책(CBZ·CBR)은 없어도 읽을 수 있어요.",
"engines.package.size": "다운로드 {0} · 설치 후 {1}",
+ "engines.progress_detail": "{0} / {1} · {2}/s · {3}",
+ "engines.eta.estimating": "남은 시간 계산 중…",
+ "engines.eta.seconds": "{0}초 남음",
+ "engines.eta.minutes": "{0}분 남음",
"engines.install": "설치",
"engines.cancel": "취소",
"engines.remove": "제거",
diff --cc src/Filee.App/Assets/i18n/zh-CN.json
index 19d91d11,ca3269c5..974ea246
--- a/src/Filee.App/Assets/i18n/zh-CN.json
+++ b/src/Filee.App/Assets/i18n/zh-CN.json
@@@ -315,18 -237,12 +315,20 @@@
"engines.optional_description": "体积较大的引擎仅在需要时下载。更新 Filee 时会保留,卸载时一并删除。",
"engines.all_title": "全部引擎",
"engines.package.libreoffice.name": "LibreOffice(旧版和少见格式)",
- "engines.package.libreoffice.description": "仅用于较旧或不常见的格式:DOC、XLS、PPT 和 OpenDocument 文件,转换为 DOCX、ODT 和 ODS,以及 HWP → DOCX(含 H2Orestart 过滤器和 Java)。DOCX、XLSX、PPTX 和 CSV 无需它即可转换。",
- "engines.package.pandoc.name": "Pandoc(HTML 与 Markdown ↔ Word)",
- "engines.package.pandoc.description": "支持 Markdown ↔ DOCX、ODT、RTF,以及 ODT、RTF → HWPX。Markdown 和 HTML → PDF、HWPX,Markdown → HTML、TXT,以及 DOCX → HWPX 无需此引擎。",
+ "engines.package.libreoffice.description": "仅用于较旧或不常见的格式:DOC、XLS、PPT 和 OpenDocument 文件,WordPerfect、Works,Apple Pages、Numbers 和 Keynote,Publisher、CorelDRAW 和 Visio,转换为 ODT、ODS 和 ODP,以及 HWP → DOCX(含 H2Orestart 过滤器和 Java)。DOCX、XLSX、PPTX、CSV 和 PDF 无需它即可转换。",
+ "engines.package.pandoc.name": "Pandoc(Markdown、HTML、LaTeX ↔ Word)",
+ "engines.package.pandoc.description": "支持 DOCX、ODT、RTF → Markdown,reStructuredText 和 LaTeX ↔ Markdown、HTML、DOCX,以及 HTML、ODT、RTF、reStructuredText、LaTeX → HWPX。Markdown → PDF、DOCX、HWPX、HTML 和 TXT 无需此引擎。",
+ "engines.package.ghostscript.name": "Ghostscript(EPS 与 PostScript)",
+ "engines.package.ghostscript.description": "EPS、PS 和旧版 Illustrator 文件 → PDF、PNG 等图片,以及 PDF 或 SVG → EPS/PS。SVG 和以 PDF 兼容方式保存的 AI 文件无需它即可转换。",
+ "engines.package.ffmpeg.name": "FFmpeg(视频和音频)",
+ "engines.package.ffmpeg.description": "支持视频 ↔ 视频(MP4、MOV、MKV、WEBM、AVI、WMV 等)、视频 → GIF 动图或静态图片、从视频提取声音(→ MP3、M4A、WAV 等)、音频 ↔ 音频(MP3、M4A、FLAC、WAV、OGG、OPUS 等)以及 GIF → MP4、WEBM、MOV。仅视频和音频转换需要它。",
+ "engines.package.calibre.name": "Calibre(Kindle 与少见电子书格式)",
+ "engines.package.calibre.description": "可保存为 Kindle 使用的 MOBI 和 AZW3,并转换少见的电子书格式:LIT、LRF、PDB、PML、RB、SNB、TCR,以及读取 CHM 和 OEB。EPUB、MOBI、AZW3、FB2 和漫画(CBZ、CBR)无需它即可读取。",
"engines.package.size": "下载 {0} · 占用 {1}",
+ "engines.progress_detail": "{0} / {1} · {2}/s · {3}",
+ "engines.eta.estimating": "正在估算剩余时间…",
+ "engines.eta.seconds": "剩余 {0} 秒",
+ "engines.eta.minutes": "剩余 {0} 分钟",
"engines.install": "安装",
"engines.cancel": "取消",
"engines.remove": "删除",
diff --cc src/Filee.App/ViewModels/EngineSetupViewModel.cs
index b30d627a,91b92129..453792b0
--- a/src/Filee.App/ViewModels/EngineSetupViewModel.cs
+++ b/src/Filee.App/ViewModels/EngineSetupViewModel.cs
@@@ -20,12 -20,9 +20,12 @@@ public sealed partial class EngineSetup
_loc = loc;
foreach (var package in Packages)
{
- // LibreOffice (older formats: DOC, XLS, PPT, OpenDocument) and calibre (rare e-book formats, Kindle output)
- // are large and only needed by some: offered, not pre-selected.
- package.Selected = !package.IsInstalled && package.Package.Id is not ("libreoffice" or "calibre");
+ // Large downloads are offered, not pre-selected: LibreOffice is only needed for older formats (DOC, XLS,
- // PPT, OpenDocument), FFmpeg (~100 MB) only for video and audio. Ghostscript is small but only needed for
- // EPS / PostScript.
++ // PPT, OpenDocument), FFmpeg (~100 MB) only for video and audio, calibre (~230 MB) only for rare e-book
++ // formats and Kindle output. Ghostscript is small but only needed for EPS / PostScript.
+ package.Selected = !package.IsInstalled
+ && Filee.Engines.Infrastructure.EngineDownloads.DownloadSize(package.Package) < PreselectLimit
+ && package.Package.Id != "ghostscript";
package.PropertyChanged += OnPackageChanged;
}
}
diff --cc src/Filee.Engines/Ebooks/ComicBook.cs
index 00000000,14efdd40..e66eb832
mode 000000,100644..100644
--- a/src/Filee.Engines/Ebooks/ComicBook.cs
+++ b/src/Filee.Engines/Ebooks/ComicBook.cs
@@@ -1,0 -1,214 +1,214 @@@
+ // Comic book archives: CBZ (ZIP), CBR (RAR), CB7 (7-Zip), CBT (TAR) and CBC (a ZIP of CBZ files) are pictures in
+ // an archive, read with SharpCompress (MIT). Pages are sorted by name the way people number them ("page2" before
+ // "page10"). Comics become PDF (one page per picture, sized like the picture, JPEGs embedded as they are), EPUB
+ // (fixed layout) or CBZ; PDF becomes CBZ by rendering its pages with PDFium.
+
+ using System.IO.Compression;
+ using Filee.Core.Conversion;
+ using ImageMagick;
+ using PdfSharp.Drawing;
+ using PdfSharp.Pdf;
+ using PDFtoImage;
+ using SharpCompress.Archives;
+ using SkiaSharp;
+
+ // PDFtoImage marks its API for the platforms PDFium ships for (Windows, macOS, Linux, mobile); Filee only targets
+ // desktop platforms that are all covered.
+ #pragma warning disable CA1416
+
+ namespace Filee.Engines.Ebooks;
+
+ internal static class ComicBook
+ {
+ private static readonly HashSet<string> PictureExtensions =
+ [".jpg", ".jpeg", ".jpe", ".jfif", ".png", ".gif", ".webp", ".bmp", ".avif", ".jxl", ".tif", ".tiff", ".heic", ".heif"];
+
+ /// <summary>Extracts the pages of a comic archive into <paramref name="folder"/>, in reading order.</summary>
+ public static List<string> ExtractPages(string path, string format, string folder, CancellationToken cancellationToken)
+ {
+ if (format == "cbc")
+ {
+ // A collection: the CBZ files inside, in the order of comics.txt ("file.cbz:Title" per line) or by name.
+ var comics = ExtractArchive(path, EbookFiles.NewFolder(folder, "cbc"), f => Path.GetExtension(f).Equals(".cbz", StringComparison.OrdinalIgnoreCase) || Path.GetFileName(f).Equals("comics.txt", StringComparison.OrdinalIgnoreCase), cancellationToken);
+ var list = comics.FirstOrDefault(c => Path.GetFileName(c).Equals("comics.txt", StringComparison.OrdinalIgnoreCase));
+ var books = comics.Where(c => c != list).ToList();
+ if (list is not null)
+ {
+ var order = File.ReadAllLines(list).Select(l => l.Split(':')[0].Trim()).Where(l => l.Length > 0).ToList();
+ books = [.. books.OrderBy(b => order.FindIndex(o => b.EndsWith(o.Replace('/', Path.DirectorySeparatorChar), StringComparison.OrdinalIgnoreCase)) is var i and >= 0 ? i : int.MaxValue)];
+ }
+ return [.. books.SelectMany(book => ExtractPages(book, "cbz", EbookFiles.NewFolder(folder, "cbz"), cancellationToken))];
+ }
+ var pages = ExtractArchive(path, folder, f => PictureExtensions.Contains(Path.GetExtension(f).ToLowerInvariant()), cancellationToken);
+ if (pages.Count == 0)
+ throw new InvalidDataException("The comic contains no pictures.");
+ return pages;
+ }
+
+ /// <summary>Extracts the matching entries (skipping macOS metadata) and returns them sorted naturally by path.</summary>
+ private static List<string> ExtractArchive(string path, string folder, Func<string, bool> wanted, CancellationToken cancellationToken)
+ {
+ var files = new List<(string Key, string File)>();
+ IArchive archive;
+ try
+ {
- archive = ArchiveFactory.OpenArchive(path, null);
++ archive = ArchiveFactory.Open(path, null);
+ }
+ catch (Exception ex) when (ex is InvalidOperationException or InvalidDataException or ArgumentException or NotSupportedException or SharpCompress.Common.ArchiveException)
+ {
+ throw new InvalidDataException("The comic archive cannot be opened (damaged, or not the format its extension says).", ex);
+ }
+ using (archive)
+ {
- if (archive.IsEncrypted)
++ if (archive.Entries.Any(e => e.IsEncrypted))
+ throw new InvalidOperationException("The comic archive is password-protected.");
+ if (archive.IsSolid || archive.Type == SharpCompress.Common.ArchiveType.SevenZip)
+ {
+ // Sequential extraction: random access would decompress a solid block again for every entry.
+ using var reader = archive.ExtractAllEntries();
+ while (reader.MoveToNextEntry())
+ {
+ if (Wanted(reader.Entry) is { } target)
+ {
+ using var output = File.Create(target);
+ reader.WriteEntryTo(output);
+ }
+ }
+ }
+ else
+ {
+ foreach (var entry in archive.Entries)
+ {
+ if (Wanted(entry) is not { } target)
+ continue;
+ using var input = entry.OpenEntryStream();
+ using var output = File.Create(target);
+ input.CopyTo(output);
+ }
+ }
+ }
+ return [.. files.OrderBy(f => f.Key, NaturalComparer.Instance).Select(f => f.File)];
+
+ // The file to extract an entry to, or null for folders, macOS metadata and unwanted files.
+ string? Wanted(SharpCompress.Common.IEntry entry)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ var key = entry.Key ?? "";
+ var name = Path.GetFileName(key.Replace('\\', '/'));
+ if (entry.IsDirectory || key.Contains("__MACOSX", StringComparison.OrdinalIgnoreCase) || name.StartsWith('.') || !wanted(name))
+ return null;
+ if (entry.IsEncrypted)
+ throw new InvalidOperationException("The comic archive is password-protected.");
+ var target = Path.Combine(folder, $"{files.Count:00000}{Path.GetExtension(name).ToLowerInvariant()}");
+ files.Add((key, target));
+ return target;
+ }
+ }
+
+ /// <summary>One PDF page per picture, each as large as its picture (at its DPI, else 96 dpi).</summary>
+ public static void ToPdf(IReadOnlyList<string> pages, string output, string workFolder, IProgress<double>? progress, CancellationToken cancellationToken)
+ {
+ var converted = EbookFiles.NewFolder(workFolder, "pdf-pages");
+ using var document = new PdfDocument();
+ for (var i = 0; i < pages.Count; i++)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ // JPEG and PNG go in as they are (PDFsharp embeds JPEG data without re-encoding); others become one of them.
+ if (EbookFiles.CommonImage(pages[i], converted, gifAndSvg: false) is not ({ } file, _))
+ continue;
+ var info = new MagickImageInfo(file);
+ var dpi = info.Density is { X: >= 36 } density ? density.Units == DensityUnit.PixelsPerCentimeter ? density.X * 2.54 : density.X : 96;
+ using var image = XImage.FromFile(file);
+ var page = document.AddPage();
+ page.Width = XUnit.FromPoint(info.Width / dpi * 72);
+ page.Height = XUnit.FromPoint(info.Height / dpi * 72);
+ using (var graphics = XGraphics.FromPdfPage(page))
+ graphics.DrawImage(image, 0, 0, page.Width.Point, page.Height.Point);
+ progress?.Report((i + 1.0) / pages.Count);
+ }
+ if (document.PageCount == 0)
+ throw new InvalidDataException("The comic contains no readable pictures.");
+ document.Save(output);
+ }
+
+ /// <summary>Writes pages into a CBZ (stored: pictures do not compress further), numbered in order.</summary>
+ public static void ToCbz(IReadOnlyList<string> pages, string output, CancellationToken cancellationToken)
+ {
+ var temp = output + ".tmp";
+ using (var zip = ZipFile.Open(temp, ZipArchiveMode.Create))
+ {
+ var digits = Math.Max(3, pages.Count.ToString(System.Globalization.CultureInfo.InvariantCulture).Length);
+ for (var i = 0; i < pages.Count; i++)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ var name = (i + 1).ToString(System.Globalization.CultureInfo.InvariantCulture).PadLeft(digits, '0') + Path.GetExtension(pages[i]).ToLowerInvariant();
+ zip.CreateEntryFromFile(pages[i], name, CompressionLevel.NoCompression);
+ }
+ }
+ File.Move(temp, output, overwrite: true);
+ }
+
+ /// <summary>
+ /// Renders the PDF's pages (the preset's page range) as JPEG files at the preset's DPI and quality. PDFtoImage
+ /// serializes its calls into PDFium (not thread-safe), so this may run next to PdfiumConverter.
+ /// </summary>
+ public static List<string> RenderPdf(string pdf, ConversionStep step, string folder, IProgress<double>? progress, CancellationToken cancellationToken)
+ {
+ var bytes = File.ReadAllBytes(pdf);
+ var pageNumbers = PageRange.Parse(step.Preset.Pdf.PageRange, Conversion.GetPageCount(bytes, null));
+ var dpi = Math.Clamp(step.Preset.Pdf.RenderDpi, 36, 600);
+ var quality = Math.Clamp(step.Preset.Image.Quality, 1, 100);
+ var options = new RenderOptions(Dpi: dpi, WithAnnotations: true, WithFormFill: true, BackgroundColor: SKColors.White);
+ var pages = new List<string>();
+ foreach (var bitmap in Conversion.ToImages(bytes, pageNumbers, null, options))
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ using (bitmap)
+ using (var data = bitmap.Encode(SKEncodedImageFormat.Jpeg, quality))
+ {
+ var file = Path.Combine(folder, $"{pages.Count + 1:00000}.jpg");
+ File.WriteAllBytes(file, data.ToArray());
+ pages.Add(file);
+ }
+ progress?.Report(0.9 * pages.Count / Math.Max(1, pageNumbers.Count));
+ }
+ return pages;
+ }
+ }
+
+ /// <summary>Compares names the way people number pages: digit runs by value ("p2" &lt; "p10"), case-insensitively.</summary>
+ internal sealed class NaturalComparer : IComparer<string>
+ {
+ public static readonly NaturalComparer Instance = new();
+
+ public int Compare(string? x, string? y)
+ {
+ if (x is null || y is null)
+ return string.CompareOrdinal(x, y);
+ int i = 0, j = 0;
+ while (i < x.Length && j < y.Length)
+ {
+ if (char.IsAsciiDigit(x[i]) && char.IsAsciiDigit(y[j]))
+ {
+ var startX = i;
+ var startY = j;
+ while (i < x.Length && char.IsAsciiDigit(x[i]))
+ i++;
+ while (j < y.Length && char.IsAsciiDigit(y[j]))
+ j++;
+ var numberX = x[startX..i].TrimStart('0');
+ var numberY = y[startY..j].TrimStart('0');
+ var byValue = numberX.Length != numberY.Length ? numberX.Length.CompareTo(numberY.Length) : string.CompareOrdinal(numberX, numberY);
+ if (byValue != 0)
+ return byValue;
+ continue;
+ }
+ var byChar = char.ToLowerInvariant(x[i]).CompareTo(char.ToLowerInvariant(y[j]));
+ if (byChar != 0)
+ return byChar;
+ i++;
+ j++;
+ }
+ return (x.Length - i).CompareTo(y.Length - j);
+ }
+ }
diff --cc src/Filee.Engines/EngineRegistry.cs
index e57508d7,847c2805..3e0e9d07
--- a/src/Filee.Engines/EngineRegistry.cs
+++ b/src/Filee.Engines/EngineRegistry.cs
@@@ -1,16 -1,11 +1,17 @@@
// THE place where conversion engines are registered. Adding an engine = one line in CreateAll.
using Filee.Core.Conversion;
+using Filee.Engines.Archives;
+using Filee.Engines.Cad;
+ using Filee.Engines.Ebooks;
+using Filee.Engines.Email;
+using Filee.Engines.Fonts;
using Filee.Engines.Hwp;
using Filee.Engines.Hwp.Hwpx;
+using Filee.Engines.Icns;
using Filee.Engines.Infrastructure;
using Filee.Engines.Magick;
+using Filee.Engines.Media;
using Filee.Engines.Office;
using Filee.Engines.Pdf;
using Filee.Engines.Text;
@@@ -35,19 -29,10 +36,21 @@@ public static class EngineRegistr
new UnhwpConverter(),
new MarkdownConverter(),
new SpreadsheetConverter(),
+ new OoxmlConverter(),
new HwpxConverter(),
+ new ArchiveConverter(),
+ new VectorConverter(),
+ new IcnsConverter(),
+ new FontConverter(),
+ new DocxWriterConverter(),
+ new PdfTextConverter(),
+ new EmlConverter(),
+ new FfmpegConverter(),
+ new CadConverter(),
+ new EbookConverter(),
new PandocConverter(),
+ new GhostscriptConverter(),
+ new CalibreConverter(),
new LibreOfficeConverter(env),
];
diff --cc src/Filee.Engines/Filee.Engines.csproj
index c8a21e69,83c8f1ff..16dd1af1
--- a/src/Filee.Engines/Filee.Engines.csproj
+++ b/src/Filee.Engines/Filee.Engines.csproj
@@@ -18,12 -18,8 +18,13 @@@
<PackageReference Include="Unhwp" />
<PackageReference Include="Markdig" />
<PackageReference Include="ExcelNumberFormat" />
- <PackageReference Include="AngleSharp" />
+ <PackageReference Include="Svg.Skia" />
<PackageReference Include="SharpCompress" />
+ <PackageReference Include="ExcelDataReader" />
+ <PackageReference Include="PdfPig" />
+ <PackageReference Include="MimeKitLite" />
+ <PackageReference Include="ACadSharp" />
++ <PackageReference Include="AngleSharp" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
</ItemGroup>
diff --cc src/Filee.Engines/Hwp/Hwpx/DocumentReaders.cs
index 5c9a7fd9,00000000..7534e5d7
mode 100644,000000..100644
--- a/src/Filee.Engines/Hwp/Hwpx/DocumentReaders.cs
+++ b/src/Filee.Engines/Hwp/Hwpx/DocumentReaders.cs
@@@ -1,157 -1,0 +1,167 @@@
+// The one place that knows how to read a file of some format into the document model (HDocument). The HWPX writer
+// (HwpxConverter) and the DOCX writer (DocxWriterConverter) take their input formats from here, so a new reader is one
+// line in BuiltIn and both writers (and every route through them) pick it up.
+
+using System.Text;
+using System.Text.Json.Nodes;
++using Filee.Engines.Ebooks;
+using Filee.Engines.Hwp.Hwpx.Docx;
+using Filee.Engines.Hwp.Hwpx.Pptx;
+using Filee.Engines.Infrastructure;
+using Filee.Engines.Office;
+using Filee.Engines.Office.Sheets;
+using Filee.Engines.Pdf;
+
+namespace Filee.Engines.Hwp.Hwpx;
+
+/// <summary>Registry of document readers: format id → reader.</summary>
+internal static class DocumentReaders
+{
+ private static readonly TimeSpan PandocTimeout = TimeSpan.FromMinutes(2);
+
+ /// <summary>
+ /// Readers built into Filee: (input file, folder for extracted pictures) → document. Office Open XML variants
+ /// (macro-enabled files, templates, slide shows) share the reader of their family.
+ /// </summary>
+ private static readonly Dictionary<string, Func<string, string, HDocument>> BuiltIn = new(StringComparer.OrdinalIgnoreCase)
+ {
+ ["docx"] = DocxReader.Read,
+ ["docm"] = DocxReader.Read,
+ ["dotx"] = DocxReader.Read,
+ ["dotm"] = DocxReader.Read,
+ ["txt"] = (path, _) => TextDocument(File.ReadAllBytes(path)),
+ ["md"] = (path, _) => MarkdownReader.Read(DecodeText(File.ReadAllBytes(path)), Path.GetDirectoryName(Path.GetFullPath(path))!),
+ ["xlsx"] = (path, _) => SheetDocument.Build(XlsxReader.Read(path)),
+ ["xlsm"] = (path, _) => SheetDocument.Build(XlsxReader.Read(path)),
+ ["xltx"] = (path, _) => SheetDocument.Build(XlsxReader.Read(path)),
+ ["csv"] = (path, _) => SheetDocument.Build(CsvFormat.Read(path)),
+ ["tsv"] = (path, _) => SheetDocument.Build(SpreadsheetConverter.Read(path, "tsv")),
+ ["xls"] = (path, _) => SheetDocument.Build(SpreadsheetConverter.Read(path, "xls")),
+ ["ods"] = (path, _) => SheetDocument.Build(SpreadsheetConverter.Read(path, "ods")),
+ ["pptx"] = PptxReader.Read,
+ ["pptm"] = PptxReader.Read,
+ ["potx"] = PptxReader.Read,
+ ["ppsx"] = PptxReader.Read,
+ ["pdf"] = PdfDocumentReader.Read,
+ // HWP comes here as HWPX, converted by rhwp first (the route planner adds that step).
+ ["hwpx"] = HwpxReader.Read,
++ ["html"] = HtmlReader.Read,
++ ["epub"] = EpubReader.Read,
++ ["mobi"] = MobiReader.Read,
++ ["azw3"] = MobiReader.Read,
++ ["azw"] = MobiReader.Read,
++ ["prc"] = MobiReader.Read,
++ ["fb2"] = Fb2Reader.Read,
++ ["htmlz"] = ZippedText.ReadHtmlz,
++ ["txtz"] = ZippedText.ReadTxtz,
+ };
+
+ /// <summary>
+ /// Formats read through Pandoc's JSON AST (PandocAstReader) when Pandoc is installed: format id → Pandoc reader.
+ /// A built-in reader for the same format wins.
+ /// </summary>
+ private static readonly Dictionary<string, string> ThroughPandoc = new(StringComparer.OrdinalIgnoreCase)
+ {
+ ["odt"] = "odt",
+ ["rtf"] = "rtf",
+ ["html"] = "html",
+ ["rst"] = "rst",
+ ["tex"] = "latex",
+ };
+
+ /// <summary>Formats read without any optional engine.</summary>
+ public static IEnumerable<string> BuiltInFormats => BuiltIn.Keys;
+
+ /// <summary>Formats that need Pandoc (those without a built-in reader).</summary>
+ public static IEnumerable<string> PandocFormats => ThroughPandoc.Keys.Where(f => !BuiltIn.ContainsKey(f));
+
+ /// <summary>Every readable format; the Pandoc ones only when Pandoc is available.</summary>
+ public static IEnumerable<string> Formats(bool pandoc) => pandoc ? BuiltInFormats.Concat(PandocFormats) : BuiltInFormats;
+
+ /// <summary>True when <paramref name="format"/> can only be read with Pandoc.</summary>
+ public static bool NeedsPandoc(string format) => !BuiltIn.ContainsKey(format) && ThroughPandoc.ContainsKey(format);
+
+ /// <summary>Reads <paramref name="path"/> (of format <paramref name="format"/>) into the document model.</summary>
+ /// <param name="workDirectory">Scratch folder of the job: extracted pictures go into a new folder inside it.</param>
+ public static async Task<HDocument> ReadAsync(string path, string format, string workDirectory, CancellationToken cancellationToken)
+ {
+ var media = Path.Combine(workDirectory, $"media-{Guid.NewGuid():N}");
+ if (BuiltIn.TryGetValue(format, out var reader))
+ return await Task.Run(() => reader(path, media), cancellationToken);
+ if (ThroughPandoc.TryGetValue(format, out var pandocReader))
+ return await ReadWithPandocAsync(path, pandocReader, workDirectory, media, cancellationToken);
+ throw new NotSupportedException($"There is no document reader for {format.ToUpperInvariant()} files.");
+ }
+
+ // ───────────────────────── Pandoc ─────────────────────────
+
+ private static async Task<HDocument> ReadWithPandocAsync(string path, string pandocReader, string workDirectory, string media, CancellationToken cancellationToken)
+ {
+ var pandoc = PandocConverter.Locate() ?? throw new InvalidOperationException("Pandoc was not found.");
+ var json = Path.Combine(workDirectory, $"ast-{Guid.NewGuid():N}.json");
+ var inputFolder = Path.GetDirectoryName(Path.GetFullPath(path))!;
+
+ // Working directory = the input's folder, so relative image paths in HTML and LaTeX resolve.
+ var result = await ProcessRunner.RunAsync(pandoc,
+ [path, "-f", pandocReader, "-t", "json", "--extract-media=" + media, "-o", json],
+ PandocTimeout, cancellationToken, workingDirectory: inputFolder);
+ if (!File.Exists(json))
+ throw new InvalidOperationException($"Pandoc failed (exit {result.ExitCode}). {result.StandardError.Trim()}");
+ var ast = JsonNode.Parse(await File.ReadAllTextAsync(json, cancellationToken))
+ ?? throw new InvalidDataException("Pandoc produced an empty document.");
+ return PandocAstReader.Read(ast, target => ResolveImage(target, inputFolder));
+ }
+
+ /// <summary>Images extracted by Pandoc have absolute paths; HTML may use paths relative to the input.</summary>
+ private static string? ResolveImage(string target, string inputFolder)
+ {
+ if (string.IsNullOrWhiteSpace(target) || target.Contains("://", StringComparison.Ordinal))
+ return null;
+ var path = Uri.UnescapeDataString(target);
+ foreach (var candidate in new[] { path, Path.Combine(inputFolder, path) })
+ {
+ try
+ {
+ if (File.Exists(candidate))
+ return Path.GetFullPath(candidate);
+ }
+ catch (ArgumentException) { }
+ }
+ return null;
+ }
+
+ // ───────────────────────── Plain text ─────────────────────────
+
+ /// <summary>Plain text: one paragraph per line, text kept verbatim.</summary>
+ internal static HDocument TextDocument(byte[] bytes)
+ {
+ var section = new HSection();
+ foreach (var line in DecodeText(bytes).Replace("\r\n", "\n").Split('\n'))
+ {
+ var paragraph = new HParagraph();
+ if (line.Length > 0)
+ paragraph.Inlines.Add(new HText(line, default));
+ section.Blocks.Add(paragraph);
+ }
+ var document = new HDocument();
+ document.Sections.Add(section);
+ return document;
+ }
+
+ /// <summary>UTF-8 (with or without BOM) or UTF-16 with BOM; anything else is read as CP949, common for Korean text.</summary>
+ internal static string DecodeText(byte[] bytes)
+ {
+ if (bytes is [0xFF, 0xFE, ..] or [0xFE, 0xFF, ..])
+ return new StreamReader(new MemoryStream(bytes), detectEncodingFromByteOrderMarks: true).ReadToEnd();
+ try
+ {
+ var text = new UTF8Encoding(false, throwOnInvalidBytes: true).GetString(bytes);
+ return text.Length > 0 && text[0] == '' ? text[1..] : text;
+ }
+ catch (DecoderFallbackException)
+ {
+ Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
+ return Encoding.GetEncoding(949).GetString(bytes);
+ }
+ }
+}
diff --cc src/Filee.Engines/Hwp/Hwpx/HwpxConverter.cs
index e2932d98,12fc6e82..883f0d12
--- a/src/Filee.Engines/Hwp/Hwpx/HwpxConverter.cs
+++ b/src/Filee.Engines/Hwp/Hwpx/HwpxConverter.cs
@@@ -1,16 -1,21 +1,18 @@@
-// Anything → HWPX without Hancom Office: a reader turns the source into the HWPX document model and HwpxWriter
-// writes the OWPML package.
-// * DOCX is read directly (Docx/DocxReader), keeping page setup, headers/footers, columns, text boxes and formatting.
-// * TXT needs no reader: one paragraph per line.
-// * Markdown is parsed with Markdig (MarkdownReader), no external engine needed.
-// * XLSX and CSV are read directly (Office/Sheets); every sheet becomes a table (SheetDocument).
-// * PPTX is read directly (Pptx/PptxReader): one page per slide with the objects floating at their places.
-// * HTML is parsed with AngleSharp (HtmlReader), no external engine needed.
-// * ODT and RTF are parsed by Pandoc (optional engine) into its JSON AST (PandocAstReader).
+// Anything → HWPX without Hancom Office: a reader from DocumentReaders turns the source into the HWPX document model
+// and HwpxWriter writes the OWPML package.
+// * DOCX (and DOCM / DOTX / DOTM) is read directly (Docx/DocxReader), keeping page setup, headers/footers, columns,
+// text boxes and formatting.
+// * TXT needs no reader: one paragraph per line. Markdown is parsed with Markdig (MarkdownReader).
+// * XLSX / XLSM / XLTX and CSV are read directly (Office/Sheets); every sheet becomes a table (SheetDocument).
+// * PPTX / PPTM / POTX / PPSX are read directly (Pptx/PptxReader): one page per slide.
+// * PDF is read with PdfPig (Pdf/PdfDocumentReader): text in reading order, headings, pictures, scans as images.
- // * HTML, ODT, RTF, reStructuredText and LaTeX are parsed by Pandoc (optional engine) into its JSON AST.
++// * HTML (HtmlReader, AngleSharp), EPUB, MOBI / AZW3, FB2, HTMLZ and TXTZ (Ebooks) and HWPX (HwpxReader) are read
++// directly.
++// * ODT, RTF, reStructuredText and LaTeX are parsed by Pandoc (optional engine) into its JSON AST.
-using System.Text;
-using System.Text.Json.Nodes;
using Filee.Core.Conversion;
-using Filee.Engines.Hwp.Hwpx.Docx;
-using Filee.Engines.Hwp.Hwpx.Pptx;
using Filee.Engines.Infrastructure;
using Filee.Engines.Office;
-using Filee.Engines.Office.Sheets;
namespace Filee.Engines.Hwp.Hwpx;
diff --cc src/Filee.Engines/Infrastructure/EngineDownloads.cs
index ab8d7d74,93151341..45fbd3a1
--- a/src/Filee.Engines/Infrastructure/EngineDownloads.cs
+++ b/src/Filee.Engines/Infrastructure/EngineDownloads.cs
@@@ -6,10 -6,7 +6,10 @@@ using System.Text.Json
namespace Filee.Engines.Infrastructure;
/// <summary>One download from engines.json.</summary>
-/// <param name="Kind">"zip" (extracted), "msi" (administrative install, no system changes; LibreOffice, calibre) or "oxt" (LibreOffice extension).</param>
+/// <param name="Kind">
- /// "zip" (extracted), "msi" (administrative install, no system changes), "oxt" (LibreOffice extension) or "conda"
- /// (conda-forge package: its Windows binaries are extracted).
++/// "zip" (extracted), "msi" (administrative install, no system changes; LibreOffice, calibre), "oxt" (LibreOffice
++/// extension) or "conda" (conda-forge package: its Windows binaries are extracted).
+/// </param>
/// <param name="Size">Download size in bytes.</param>
public sealed record EngineComponent(string Id, string Version, string Url, string Sha256, long Size, string Kind);
@@@ -31,9 -28,7 +31,10 @@@ public static class EngineDownload
[
new("libreoffice", ["libreoffice", "h2orestart", "jre"], 1_265_000_000, ["libreoffice"]),
new("pandoc", ["pandoc"], 236_000_000, ["pandoc"]),
+ // Ghostscript from conda-forge plus the Microsoft C++ runtime it was built against (copied next to it).
+ new("ghostscript", ["ghostscript", "vcruntime"], 31_000_000, ["ghostscript"]),
+ new("ffmpeg", ["ffmpeg"], 272_000_000, ["ffmpeg"]),
+ new("calibre", ["calibre"], 663_000_000, ["calibre"]),
];
/// <summary>Total download size of a package in bytes.</summary>
diff --cc src/Filee.Engines/Infrastructure/EngineInstaller.cs
index 19359010,ced397e3..8a177419
--- a/src/Filee.Engines/Infrastructure/EngineInstaller.cs
+++ b/src/Filee.Engines/Infrastructure/EngineInstaller.cs
@@@ -3,10 -3,8 +3,10 @@@
// * Every download is checked against the SHA-256 pinned in engines.json before anything is unpacked.
// * Unpacking happens in a staging folder that replaces the engine folder only when complete, so a failed or
// cancelled install never leaves a half-installed engine behind.
- // * The LibreOffice MSI is unpacked with an administrative install (msiexec /a): files only, no registry entries,
- // no admin rights. Parts headless conversion never uses (help, gallery, most dictionaries) are removed.
+ // * MSIs (LibreOffice, calibre) are unpacked with an administrative install (msiexec /a): files only, no registry
+ // entries, no admin rights. Parts headless LibreOffice never uses (help, gallery, most dictionaries) are removed.
+// * conda-forge packages (Ghostscript, the Microsoft C++ runtime) are zip files holding zstd-compressed tarballs;
+// only their Windows binaries (Library/bin) are unpacked, with a managed decompressor (no 7-Zip, no installer).
// * A marker file with the component's hash records what is installed, so an engines.json update is detected.
using System.Diagnostics;
@@@ -182,17 -172,9 +182,13 @@@ public sealed class EngineInstalle
Replace(component.Id, SingleRoot(staging));
break;
case "msi":
- await UnpackMsiAsync(file, staging, Path.Combine(Path.GetTempPath(), "filee-msiexec.log"), cancellationToken);
- var soffice = Directory.EnumerateFiles(staging, "soffice.exe", SearchOption.AllDirectories).FirstOrDefault()
- ?? throw new InvalidDataException("soffice.exe not found in the LibreOffice package.");
- var libreOffice = Path.GetDirectoryName(Path.GetDirectoryName(soffice)!)!; // folder with program/, share/
- TrimLibreOffice(libreOffice);
- Replace(component.Id, libreOffice);
+ await UnpackMsiAsync(component.Id, file, staging, Path.Combine(Path.GetTempPath(), "filee-msiexec.log"), cancellationToken);
+ Replace(component.Id, MsiProgramFolder(component.Id, staging));
break;
+ case "conda":
+ UnpackConda(file, staging, cancellationToken);
+ Replace(component.Id, staging);
+ break;
case "oxt":
// LibreOffice registers bundled extensions (plain folders under share/extensions) on start-up.
var extensions = Path.Combine(FolderOf("libreoffice"), "share", "extensions");
diff --cc src/Filee.Engines/Infrastructure/engines.json
index d7759e2f,039d6077..3dfc93ba
--- a/src/Filee.Engines/Infrastructure/engines.json
+++ b/src/Filee.Engines/Infrastructure/engines.json
@@@ -43,26 -36,12 +43,33 @@@
"size": 606257,
"kind": "oxt"
},
+ "ghostscript": {
+ "version": "10.08.0",
+ "url": "https://conda.anaconda.org/conda-forge/win-64/ghostscript-10.08.0-hac47afa_0.conda",
+ "sha256": "512BE9413C58B0AD3A2CD95A63EAEA73CBE32D9A6B9170C848BF825694A4ADB0",
+ "size": 19295904,
+ "kind": "conda"
+ },
+ "vcruntime": {
+ "version": "14.44.35208",
+ "url": "https://conda.anaconda.org/conda-forge/win-64/vc14_runtime-14.44.35208-h818238b_41.conda",
+ "sha256": "EC706FE9368B837FBD05AF4851F5EBEF12BEF8C471A273F4805F7AF788407317",
+ "size": 682908,
+ "kind": "conda"
+ },
+ "ffmpeg": {
+ "version": "9.0.2",
+ "url": "https://github.com/GyanD/codexffmpeg/releases/download/9.0.2/ffmpeg-9.0.2-full_build-shared.zip",
+ "sha256": "8D31E162F1616E37AAB3FA2DB991B97E1B8DBEB1C8465FD81A81BE16FF91B328",
+ "size": 99899672,
+ "kind": "zip"
++ },
+ "calibre": {
+ "version": "9.15.0",
+ "url": "https://download.calibre-ebook.com/9.15.0/calibre-64bit-9.15.0.msi",
+ "sha256": "0F96AE06165C2419607C1C66726C091A78E89E08EA69F077CF3E2C884E800853",
+ "size": 226549760,
+ "kind": "msi"
}
}
}
diff --cc tests/Filee.App.Tests/RenderTests.cs
index f49db3e1,4f6429e7..ed6d66cc
--- a/tests/Filee.App.Tests/RenderTests.cs
+++ b/tests/Filee.App.Tests/RenderTests.cs
@@@ -103,12 -66,8 +103,12 @@@ public class RenderTest
window.Show();
Pump();
- // Everything not installed is offered; small downloads are pre-selected, the large LibreOffice and FFmpeg and the
- // Everything not installed is offered; all but the large LibreOffice and calibre pre-selected.
- Assert.All(vm.Packages.Where(p => !p.IsInstalled), p => Assert.Equal(p.Package.Id is not ("libreoffice" or "calibre"), p.Selected));
++ // Everything not installed is offered; small downloads are pre-selected, the large LibreOffice, FFmpeg and calibre and the
+ // EPS-only Ghostscript not.
+ Assert.All(vm.Packages.Where(p => !p.IsInstalled), p => Assert.Equal(
+ Filee.Engines.Infrastructure.EngineDownloads.DownloadSize(p.Package) < EngineSetupViewModel.PreselectLimit
+ && p.Package.Id != "ghostscript", p.Selected));
- Assert.DoesNotContain(vm.Packages, p => p.Package.Id is "libreoffice" or "ffmpeg" or "ghostscript" && p.Selected);
++ Assert.DoesNotContain(vm.Packages, p => p.Package.Id is "libreoffice" or "ffmpeg" or "calibre" or "ghostscript" && p.Selected);
Assert.Equal(vm.Packages.Any(p => p.Selected && p.CanInstall), vm.InstallCommand.CanExecute(null));
Save(window, $"engine-setup-{language}.png");
window.Close();