Skip to content

laisuk/OpenccNetLibGui

Repository files navigation

OpenccNetLibGui

GitHub Release Total Downloads Latest Downloads Release

OpenccNetLibGui is a Chinese text conversion application built with Avalonia and the MVVM design pattern. It leverages the OpenccNetLib library to provide simplified and traditional Chinese conversion.

🚀 Download

Always get the latest version of OpenccNetLibGui from the GitHub Releases page:

On the release page, look for assets named:

  • OpenccNetLibGui-vX.Y.Z-win-x64.zipWindows (win-x64)
  • OpenccNetLibGui-vX.Y.Z-linux-x64.tar.gzLinux (linux-x64)
  • OpenccNetLibGui-vX.Y.Z-osx-arm64.tar.gzmacOS (Apple Silicon, osx-arm64)

📦 These are framework-dependent builds targeting .NET 10 (starting from v1.4.0). The .NET 10 Runtime must be installed on your system to run these builds:
.NET 10 Runtime

Features

  • Chinese Conversion
    Convert text between Simplified and Traditional Chinese using optimized OpenCC lexicons combined with an efficient FMM-based dictionary matcher.

  • Single & Batch Conversion
    Convert individual files or entire directories in one operation.

  • Wide File Format Support
    Supports most text-based file types, including:

    • Plain text (.txt, .md)
    • Subtitles (.srt, .vtt, .ass, .ttml2)
    • Office documents (.docx, .xlsx, .pptx, .odt)
    • EPUB (.epub)
    • PDF (.pdf) with intelligent CJK text reflow
  • PDF Extraction & CJK Reflow
    Import PDF files and automatically:

    • Extract text using Pdfium or PdfPig
    • Remove repetitive headers and footers (optional)
    • Merge broken lines across pages (e.g., + 面容)
    • Preserve chapter titles and headings
    • Produce clean, continuous text suitable for reading or conversion
  • Drag-and-Drop Support
    Drop text, PDF, EPUB, or Office files directly into the Source panel.

  • Safe Office/EPUB Output Generated Office and EPUB packages are validated before use and written atomically. Invalid or corrupted packages fail clearly without replacing an existing output file.

  • CJK-Aware Reflow Engine
    Smart handling of:

    • Paragraph boundaries
    • Chapter markers (第一章, 序章, etc.)
    • Chinese punctuation
    • Page-break artifacts
    • Indentation and spacing heuristics
  • Cross-Platform Avalonia GUI
    Modern MVVM-based UI that runs consistently on Windows, macOS, and Linux.


Notes

PDF Support

Only text-embedded PDFs are supported.
OpenccNetLibGui reads Unicode text directly from the PDF content stream using either Pdfium or PdfPig.

❌ Scanned PDFs or pure image-based PDFs are not supported.
Such files require OCR (Optical Character Recognition), which is not included in this application.


PDF Extraction Engines

OpenccNetLibGui offers two selectable engines for PDF text extraction:

  • Pdfium (native)
    A high-accuracy native engine with superior handling of:

    • CJK characters
    • complex layouts
    • overlapping glyphs
    • repeated text tokens
    • tricky multi-column or multi-page flows
  • PdfPig
    A pure-managed, cross-platform engine suitable for most standard text-embedded PDFs.

The preferred engine can be changed in the Settings context menu.


CJK Paragraph Reflow

The CJK paragraph reflow module is designed as a lightweight, text-only readability enhancement for extracted PDF/EPUB content.
Its goal is to restore a natural reading flow for continuous text, especially CJK novels and prose.

It focuses on:

  • Line merging for broken paragraph fragments
  • Dialogue reconstruction across line breaks
  • Basic chapter heading detection
  • Removal of common page-level extraction artifacts

Reflowed output aims for cleaner, novel-style plain-text readability, but it is not intended to:

  • reproduce original page layout
  • preserve columns, tables, or typography
  • support professional publishing or academic typesetting
  • generate print-ready or editorial-grade output

Reflow intentionally applies conservative, general heuristics that work reasonably well across many documents, rather than being optimized for any single PDF or personal formatting preference.

Users should treat reflowed text as a draft-quality starting point.
If exact formatting or document-specific behavior is required, disabling Reflow and working with raw extracted text is recommended.


Dependencies

  • Avalonia
    Cross-platform .NET UI framework used to build the application’s user interface.

  • AvaloniaEdit
    A performant text editor control with syntax-highlighting, line numbers, and virtualization support.

  • OpenccNetLib
    Core conversion engine providing optimized OpenCC dictionary handling, FMM segmentation and multi-stage dictionary pipelines for Simplified/Traditional conversion.

  • Newtonsoft.Json
    High-performance JSON serialization/deserialization library used for settings, layout recovery,
    and application configuration files.

  • UglyToad.PdfPig
    A fully managed PDF text extraction library used for:

    • Parsing PDF structure
    • Extracting raw Unicode text
    • Fallback extraction when PDFium is unavailable
      Ideal for CPU-only scenarios or when using a 100% managed dependency chain.
  • PDFium (native library + .NET binding)
    High-performance native PDF rendering & text extraction engine used for:

    • Faster page loading on large PDFs
    • More accurate CJK character extraction
    • Improved handling of rotated text, clipped glyphs, and embedded fonts
      Provides the “fast mode” when users choose PDFium in PDF Engine settings.

Getting Started

  1. Clone the repository:
git clone https://github.com/laisuk/OpenccNetLibGui.git
  1. Navigate to the project directory:
cd OpenccNetLibGui
  1. Restore dependencies:
dotnet restore
  1. Build the project:
dotnet build
  1. Run the application:
dotnet run

Usage

Single Mode

image01

PDF Text Extraction (Text-Embedded PDF) and conversion

image04

Support most text base file types, OpenDocuments (DOCX, ODT, EPUB) and Text-Embedded PDF documents.

  1. Paste the text or open a file (text, DOCX, ODT, EPUB or PDF file) you wish to convert (file/text drag and drop are supported on Windows and macOS).
  2. Select the desired conversion configuration (e.g., Simplified to Traditional).
  3. PDF options can be set in reight-click context menu.
  4. Click the Process button to see the results.

Notes

PDF Engine can be set in LanguageSettings.json as well: Where:
1 = PdfPig, 2= Pdfium

{
  "pdfEngine": 1
}

Batch Mode

image02 image03

Support most text base file types, Office documents (.docx, .xlsx, .pptx, .odt, .ods, .odp), EPUB ( .epub) and PDF (.pdf, introduced in OpenccNetLibGui v1.3.2).

  1. Select or drag file(s) into the source list box (File(s), drag and drop currently only supported on Windows and macOS).
  2. Select the desired conversion configuration.
  3. Set the output folder.
  4. For PDF document conversion, right-click List Box to set PDF Options. (PDF engine, add page header, auto-reflow CJK text etc.)
  5. Click the Batch Start button to begin batch conversion.

Dark Theme

image05

OpenccNetLibGui is Dark Theme Mode friendly.


Custom Dictionary

Usage of custom dictionary can be set in LanguageSettings.json:

{
  "dictionary": "dicts"
}

Options are:

  1. "dicts" - *.txt in directory dicts
  2. "json" - dictionary_maxlength.json
  3. "cbor" - dictionary_maxlength.cbor
  4. None of above, default to "zstd" - dictionary_maxlength.zstd

Custom Chinese Language in UI Settings (繁體界面 / 简体界面)

image06

Custom Chinese Language in UI can be set in LanguageSettings.json:

{
  "Locale": 1
}

Options are:

  1. 1 - Traditional Chinese (繁體字/傳統漢字)
  2. 2 - Simplified Chinese (简体字)
  3. 0 - English
  4. Other values - Reset to Simplified Chinese (简体字)

Contributing

Contributions are welcome! Please fork the repository and submit a pull request for any enhancements or bug fixes.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements

  • OpenCC
    For providing the high-quality Chinese conversion lexicons.
  • OpenccNet
    For the optimized .NET implementation of OpenCC used as the core engine.
  • Avalonia
    For the modern, cross-platform UI framework powering the application.
  • AvaloniaEdit
    For the performant text editor component with line numbers and virtualization.
  • Newtonsoft.Json
    For the robust and flexible JSON serialization and configuration handling.
  • PdfPig
    For the fully-managed PDF text extraction engine used in the standard extraction mode.
  • PDFium (native library + .NET bindings)
    For providing high-performance PDF rendering and fast CJK text extraction in Pdfium mode.

About

A Chinese text conversion application built with Avalonia. It leverages the OpenccNetLib library to provide simplified and traditional Chinese conversion.

Resources

License

Stars

3 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages