docx_file_viewer 1.0.0 copy "docx_file_viewer: ^1.0.0" to clipboard
docx_file_viewer: ^1.0.0 copied to clipboard

A Flutter package for rendering DOCX files with native widgets. View, zoom, search, and interact with Word documents.

docx_file_viewer #

pub package Flutter

A native Flutter DOCX viewer that renders Word documents using Flutter widgets. No WebView, no PDF conversionβ€”just pure Flutter rendering for maximum performance.

✨ Features #

Feature Description
🎯 Native Rendering Pure Flutter widgets, no WebView or PDF
πŸ“– Full DOCX Support Paragraphs, tables, lists, images, shapes
πŸ” Search Find and highlight text in documents
πŸ”Ž Zoom Pinch-to-zoom with InteractiveViewer
βœ‚οΈ Selection Select and copy text
🎨 Theming Light/dark themes, customizable
πŸ”€ Fonts Embedded font loading with OOXML deobfuscation

πŸ“¦ Installation #

Add docx_file_viewer to your pubspec.yaml:

dependencies:
  docx_file_viewer: ^1.0.0

πŸš€ Quick Start #

import 'package:docx_file_viewer/docx_viewer.dart';

// From file
DocxView.file(myFile)

// From bytes
DocxView.bytes(docxBytes)

// From path
DocxView.path('/path/to/document.docx')

// With configuration
DocxView(
  file: myFile,
  config: DocxViewConfig(
    enableSearch: true,
    enableZoom: true,
    theme: DocxViewTheme.light(),
    customFontFallbacks: ['Roboto', 'Arial'],
  ),
)

πŸ“– Usage #

Basic Viewer #

Scaffold(
  body: DocxView.file(
    File('document.docx'),
    config: DocxViewConfig(
      enableZoom: true,
      backgroundColor: Colors.white,
    ),
  ),
)
Scaffold(
  body: DocxViewWithSearch(
    file: myDocxFile,
    config: DocxViewConfig(
      enableSearch: true,
      searchHighlightColor: Colors.yellow,
    ),
  ),
)

Dark Theme #

DocxView(
  bytes: docxBytes,
  config: DocxViewConfig(
    theme: DocxViewTheme.dark(),
    backgroundColor: Color(0xFF1E1E1E),
  ),
)

With Search Controller #

final searchController = DocxSearchController();

// Widget
DocxView(
  file: myFile,
  searchController: searchController,
)

// Programmatic control
searchController.search('keyword', textIndex);
searchController.nextMatch();
searchController.previousMatch();
searchController.clear();

βš™οΈ Configuration #

Property Type Default Description
enableSearch bool true Enable search
enableZoom bool true Enable pinch-to-zoom
enableSelection bool true Enable text selection
minScale double 0.5 Minimum zoom scale
maxScale double 4.0 Maximum zoom scale
customFontFallbacks List<String> ['Roboto', 'Arial', 'Helvetica'] Font fallbacks
theme DocxViewTheme? Light Rendering theme
padding EdgeInsets 16.0 Document padding
backgroundColor Color? White Background color
searchHighlightColor Color Yellow Search highlight

🎨 Theming #

DocxViewTheme(
  defaultTextStyle: TextStyle(fontSize: 14, color: Colors.black87),
  headingStyles: {
    1: TextStyle(fontSize: 28, fontWeight: FontWeight.bold),
    2: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
    // ...
  },
  codeBlockBackground: Color(0xFFF5F5F5),
  codeTextStyle: TextStyle(fontFamily: 'monospace'),
  tableBorderColor: Color(0xFFDDDDDD),
  linkStyle: TextStyle(color: Colors.blue, decoration: TextDecoration.underline),
)

// Presets
DocxViewTheme.light()
DocxViewTheme.dark()

πŸ”— Integration with docx_creator #

This package uses docx_creator for parsing:

import 'package:docx_creator/docx_creator.dart';

// Create document
final doc = docx()
  .h1('Title')
  .p('Content')
  .build();

// Export to bytes
final bytes = await DocxExporter().exportToBytes(doc);

// View immediately
DocxView.bytes(bytes)

πŸ“‹ Supported Elements #

Element Support
Headings (H1-H6) βœ…
Paragraphs βœ…
Bold, Italic, Underline βœ…
Colors & Backgrounds βœ…
Hyperlinks βœ…
Bullet Lists βœ…
Numbered Lists βœ…
Nested Lists βœ…
Tables βœ…
Images βœ…
Shapes βœ…
Code Blocks βœ…
Embedded Fonts βœ…

Contributing #

Contributions are welcome! Please open an issue or pull request.

License #

MIT License - see LICENSE for details.

11
likes
160
points
855
downloads
screenshot

Publisher

verified publisheralihassan143cool.blogspot.com

Weekly Downloads

A Flutter package for rendering DOCX files with native widgets. View, zoom, search, and interact with Word documents.

Homepage
Repository (GitHub)
View/report issues

Topics

#docx #word #viewer #document #office

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

docx_creator, flutter, url_launcher

More

Packages that depend on docx_file_viewer