flutter_rhwp

Flutter plugin for reading, viewing, editing, saving, and exporting HWP/HWPX documents.

Features

  • Open HWP/HWPX bytes.
  • Render pages as SVG.
  • Extract text and Markdown.
  • Export HWP, HWPX, PDF, DOCX, text, Markdown, and page SVG.
  • Use RhwpViewer for Flutter-native viewing.
  • Use RhwpFullEditor for the upstream full editor UI.
  • Use RhwpCommandEditor for explicit Flutter/Rust edit commands.

Installation

Until this package is published, add it from GitHub:

dependencies:
  flutter_rhwp:
    git:
      url: https://github.com/JAICHANGPARK/flutter_rhwp.git
      ref: main

Then run:

flutter pub get

Requirements:

  • Flutter >=3.35.0
  • Windows full editor: Microsoft WebView2 runtime
  • Linux full editor: WebKitGTK 4.1
  • Sandboxed macOS full editor with remote @rhwp/editor: outgoing network client entitlement

Quick Start

import 'dart:io';

import 'package:flutter_rhwp/flutter_rhwp.dart';

final bytes = await File('sample.hwp').readAsBytes();
final document = await Rhwp.open(bytes, fileName: 'sample.hwp');

final pageCount = await document.pageCount;
final firstPageSvg = await document.renderPageSvg(0);
final text = await document.extractText();
final exportedPdf = await document.exportDocument(RhwpExportFormat.pdf);

await document.close();

Usage

Viewer:

RhwpViewer(document: document)

Full editor:

final controller = RhwpFullEditorController();

RhwpFullEditor(
  controller: controller,
  initialBytes: bytes,
  fileName: 'sample.hwp',
);

final editedHwp = await controller.exportHwp();

Command editor:

RhwpCommandEditor(document: document)

Edit with Rust bridge commands:

await document.insertText(
  section: 0,
  paragraph: 0,
  offset: 0,
  text: 'Hello',
);

Export with save metadata:

final exported = await document.exportDocument(
  RhwpExportFormat.pdf,
  sourceFileName: 'sample.hwp',
);

// exported.bytes
// exported.fileName
// exported.mimeType

Example

cd example
flutter run -d macos

The example can open the bundled HWP asset or a picked HWP/HWPX file, then export HWP/HWPX/PDF/DOCX/TXT/MD/SVG.

Notes

  • RhwpFullEditor uses upstream @rhwp/editor.
  • On Web it embeds the editor directly.
  • On Android, iOS, macOS, Windows, and Linux it uses webview_all.
  • Initial full-editor file loading uses editor.loadFile(data, fileName).
  • rust/vendor/rhwp should be committed. rust/target should stay ignored.

License

MIT. See THIRD_PARTY_NOTICES.md for bundled source and dependency notices.