[Open-source] Pure front-end file preview infrastructure for enterprise backend, internal, and private systems
![[Open-source] Pure front-end file preview infrastructure for enterprise backend, internal, and private systems](https://yy123.ink/api/img/1796366469517-24z3wg.png)
1. Project Overview
File Viewer
A pure front-end file preview component targeting enterprise backend, intranet, and private system.
No server-side transcoding is required, and Office, PDF/OFD, CAD, compressed packages, emails, images, audio/video, and code files can be previewed in the browser.
2. Open Source License
Licensed under Apache-2.0
3. Screenshots
4. Feature Overview
Project Positioning
File Viewer is a browser-native file preview component targeting business systems. Its core scenario includes enterprise backend, OA, knowledge base, ticket system, attachment center, engineering data library, and private delivery project attachments.
No backend transcoding service is required, nor is it necessary to send private files to the cloud for conversion. A single component and API cover Office, PDF, OFD, Typst, CAD, XMind, compressed packages, emails, graphics, audio/video, code, PSD, fonts, and structured data.
Currently, 206+ file extension mappings and 24 preview chains are built-in. New projects should use @file-viewer/*; @flyfish-group/* historical packages will continue to be maintained synchronously.
Highlights
- Fast access.
Vanilla JS, Vue, React, Svelte, jQuery all have native components; full package can get complete capabilities at one time. - Comprehensive coverage.
206+ extensions, 24 preview links, covering common office, engineering, design, data, and code attachments. - Pure front-end.
Browser-side parsing and rendering, supporting offline, intranet, Docker, private CDN, and strict resource self-hosting. - Modularized.
Lightweight components, renderer, preset, full package layered clearly, both simple installation and one-key full-load are supported. - On-demand loading.
PDF, Office, CAD, Typst, compressed package, drawing, PSD, Mermaid, etc. heavy capabilities only load when format is hit. - Complete operation.
Search, highlight, zoom, print, export HTML, download, watermark, theme, lifecycle hook, and button pre-validation all go through unified API. - Ecosystem consistency.
Core focuses on underlying capabilities, and framework components only do native wrapping, parameter, event, and controller experience remain consistent.
Supported Formats
Current version is embedded with 206 extension name mappings, covering 24 preview paths.
| Category |
Extension name |
Current performance |
Suitable Use Cases |
| Word |
docx、docm、dotx、dotm |
@file-viewer/renderer-word
+ Self-developed
@file-viewer/docx, Worker parsing, continuous streaming reading, directory field caching, and asynchronous batch rendering; template / macro format is processed as read-only preview |
Newly generated Word documents, formal documents, Word templates |
| Word |
doc、dot |
@file-viewer/renderer-word
+
msdoc-viewer, using Word style page container, enhanced CFB fault tolerance and table layout |
History
.doc
Old documents, Word 97-2003 templates |
| Compatible documents |
rtf、odt |
@file-viewer/renderer-word
+
rtf.js
/ ODF
content.xml
Compatible preview |
RTF rich text, OpenDocument text documents |
| Excel |
xlsx、xltx |
@file-viewer/renderer-spreadsheet
+
styled-exceljs
+ Virtual scrolling, supports size, merge, common styles, automatic text color, workbook drawing images, and optional header drag adjustment column width; default main thread parsing, static Worker needs to be explicitly enabled; print button is hidden based on ability to avoid only printing the current viewport |
Business that needs to retain table structure and styles, Excel templates |
| Excel compatible format |
xlsm、xlsb、xls、xlt、xltm、csv、ods、fods、numbers |
Unified parsing, progressive restoration of styles based on available information by format; similarly, follow the virtual table printing boundary |
Old tables, lightweight data viewing |
| PowerPoint |
pptx、pptm、potx、potm、ppsx、ppsm、odp |
Based on independent open-source
@file-viewer/pptx
Native engine browsing slide content, Worker progressive parsing and page-by-page output; ODP follows OpenDocument slide text preview |
Reports, courseware, schemes, demonstration templates |
| |
|
Based on
pdfjs-dist
Preview, same-origin URL defaults to progressive reading; server-side supports Range when automatically splitting loads, supports zoom toolbar, rotate page, page sidebar / directory tree sidebar switching, width self-adaptive, complete printing, and export HTML |
Contracts, bills, style products |
| OFD |
ofd |
Based on
DLTech21/ofd.js
Repository source code online preview domestic style documents, bypassing npm dist authorization wasm branch |
Electronic invoices, official documents, archived materials |
| Typst |
typ、typst |
Directly reading Typst source files, loading on demand
@myriaddreamin/typst.ts
Browser WASM compiler, SVG renderer, and local font assets; supports complete preview, printing, and exporting HTML |
Technical reports, draft papers, engineering document templates |
| Archives |
zip、zipx、7z、rar、tar、gz、gzip、tgz、bz2、bzip2、tbz、tbz2、xz、txz、lzma、zst、tzst、cab、ar、cpio、iso、xar、lha、lzh、jar、war、ear、apk、cbz、cbr |
@file-viewer/renderer-archive
Based on
libarchive.js
WASM Worker reads directory, click to decompress internal files as needed and reuse unified viewer, supports IndexedDB caching, ZIP/TAR/GZIP fallback, and volume limit |
Archives attachments, batch delivery packages, and compressed package documents for quick viewing |
| |
eml、msg、mbox |
@file-viewer/renderer-email
Independent handling of email links; EML/MBOX used
postal-mime, MSG used
@kenjiuno/msgreader, supports header information, HTML/text body, attachment download, and attachment preview |
Email archiving, work order emails, customer incoming attachments |
| EDA |
olb、dra、gds、oas、oasis |
@file-viewer/renderer-eda
Independent handling; used
cfb
Parses OrCAD/Allegro common CFB containers; standard GDSII reads structure, boundary, path, text, reference, small images output SVG, large element sets automatically cut to WebGL canvas; OAS/OASIS readable text version output SVG preview, real SEMI binary OASIS first does secure structure indexing, readable strings, entity candidates, and diagnostics, no false tags professional electrical/geometry inspection |
Component library, packaging drawings, chip diagram attachments initial screening |
| CAD |
dwg、dxf、dwf、dwfx、xps |
Based on
@flyfish-dev/cad-viewer
Preview drawings; DWG through Worker + LibreDWG WASM parsing, DXF using JS parser, DWF/DWFx/XPS using native
dwf-viewer
Renders W2D/W3D/XPS graphics |
Engineering drawings, two-dimensional CAD attachments, AutoCAD archived files |
| 3D models |
glb、gltf、obj、stl、ply、fbx、dae、3ds、3mf、amf、usd、usda、usdc、usdz、kmz、pcd、wrl、vrml、xyz、vtk、vtp、step、stp、iges、igs、ifc、3dm |
@file-viewer/renderer-3d
Interactive preview based on Three.js loaders; engineering CAD/BIM formats will give reasons and conversion suggestions for non-built-in geometric kernels |
Design models, point clouds, three-dimensional assets, engineering models |
| Geographic data |
geojson、kml、gpx、shp |
@file-viewer/renderer-geo
Independent handling; @tmcw/togeojson
/
shpjs
Converts GeoJSON to offline SVG preview |
Geographic attachments, tracks, boundaries, and lightweight GIS data |
| XMind mind maps |
xmind |
Based on
@ljheee/xmind-parser
Parses XMind 8 XML and XMind 2020+ JSON package structure, offline renders multiple sheet mind maps, nodes, labels, notes, links, marks, images, and directory trees, using
@panzoom/panzoom
Provides mature drag-and-drop, mobile double-finger zoom, wheel anchor zoom, keyboard translation, unified toolbar state synchronization, adaptation to canvas, search, print, HTML export, and zoom |
Mind maps, project planning, knowledge structure, meeting minutes |
| Excalidraw |
excalidraw |
Based on official
@excalidraw/excalidraw
's
restore
+
exportToSvg
Outputs read-only preview |
Whiteboard sketches, process drafts, product communication diagrams |
| draw.io |
drawio、dio |
Based on official diagrams.net
GraphViewer
Preview mxGraphModel / mxfile |
Flowchart, Architecture Diagram, Business Swimlane Diagram |
| Mermaid |
mermaid、mmd |
@file-viewer/renderer-drawing
Officially loaded on demand
mermaid, output theme-adaptive SVG, and through
@panzoom/panzoom
Support drag, zoom, reset, and unified toolbar synchronization |
Architecture Diagram, Flowchart, State Diagram, Sequence Diagram |
| PlantUML |
plantuml、puml |
Usage
plantuml-encoder
Generate render payload, support configure self-hosted PlantUML SVG service; Preview layer also supports drag, zoom, and theme container adaptation |
UML Sequence Diagram, Component Diagram, Deployment Diagram |
| E-book |
epub |
@file-viewer/renderer-epub
Based on
epubjs
Parse directory and chapter resources, use compatibility better scrolling reading |
E-book, Training Manual, Long-form Reading Materials |
| E-book |
umd |
Load UMD mobile e-book structure metadata, directory, and zlib compressed content on demand |
Old mobile e-book, Historical Novel Attachments |
| Markdown |
md、markdown |
@file-viewer/renderer-text
Provide Markdown reading style, support light and dark theme reading face |
README, Knowledge Document, Instructional Document |
| Image |
gif、jpg、jpeg、bmp、tiff、tif、png、svg、webp、avif、ico、heic、heif、jxl |
Native image browsing; HEIC/HEIF hit when needed
heic2any
Conversion |
Image Attachments, Design Drafts, Logo, Mobile Photos |
| Code / Text |
txt、json、jsonc、json5、ipynb、yaml、yml、toml、ini、proto、hcl、tex、gv、http、js、mjs、cjs、jsx、ts、tsx、vue、react、css、html、htm、xml、log、java、py、go、rs、rb、swift、kt、php、c、cpp、cc、h、hpp、cs、sh、bash、sql、diff、patch、bundle、bdl |
@file-viewer/renderer-text
Usage
highlight.js
Lightweight highlighting; patch load on demand
diff2html
Do left and right comparison, git bundle parse refs, history, file tree, and readable blob content |
Log, Configuration, Code Snippets, Interface Responses, Code Reviews |
| Audio |
mp3、mpeg、wav、ogg、oga、opus、m4a、aac、flac、weba、midi、mid |
@file-viewer/renderer-media
Use browser native audio playback; MIDI hit when needed load
@tonejs/midi
Display track structure |
Recording, Podcasts, Voice Attachments, Sound Materials, MIDI Files |
| Video |
mp4、webm、m3u8 |
@file-viewer/renderer-media
Use browser native video playback; HLS manifest necessary when needed load
hls.js |
Demonstration Videos, Screen Recording, HLS Streams |
| Fonts / Design / Data |
ttf、otf、woff、woff2、psd、ai、eps、sqlite、wasm、parquet、avro、webarchive |
@file-viewer/renderer-data
Independent handling, based on FontFace, ag-psd, sql.js, hyparquet, avsc, WebAssembly Module, and secure digest; PSD support layer selection visibility, redraw, and unified scaling; SQLite WASM support private configuration |
Fonts, Design Assets, Databases, Columnar Data, and Web Archives |
5. Tech Stack
Quick Start
First choose the interface layer, then load format capabilities on demand. If you want to get the complete experience as quickly as possible, use the *-full package directly.
| Scenario |
Recommended Installation |
| Script Tag / CDN Complete Capability |
@file-viewer/web-full |
| Vanilla JS npm |
@file-viewer/web
+
@file-viewer/preset-all |
| Vue 3 |
@file-viewer/vue3-full, or
@file-viewer/vue3
+ preset |
| Vue 2.7 / 2.6 |
@file-viewer/vue2.7-full
/
@file-viewer/vue2.6-full |
| React 18/19 |
@file-viewer/react-full |
| React 16.8/17 |
@file-viewer/react-legacy-full |
| Svelte |
@file-viewer/svelte-full |
| jQuery |
@file-viewer/jquery-full |
| Accurate cropping |
Any component package +
@file-viewer/preset-*
or independent renderer |
CDN / Script Tag
<script src="https://cdn.jsdelivr.net/npm/@file-viewer/web-full@latest/dist/flyfish-file-viewer-web-full.iife.js"></script><flyfish-file-viewersrc="/files/report.pdf"theme="light"toolbar-position="bottom-right"style="display:block;height:720px"></flyfish-file-viewer>
web-full CDN IIFE first package only registers Custom Element, controller, and lazy full preset; PDF, Word, Excel, CAD, Typst, compressed package, etc. heavyweight renderer will be loaded asynchronously from dist/renderers/*.iife.js when hitting file type; Worker, WASM, fonts, and vendor resources continue to be automatically parsed by script URL, and internal deployment can mirror the dist directory to their own static domain.
Vanilla JS
npm i @file-viewer/web @file-viewer/preset-all
import { mountViewer } from '@file-viewer/web'import presetAll from '@file-viewer/preset-all'mountViewer(document.querySelector('#viewer')!, {url: '/files/report.docx',options: { preset: presetAll, theme: 'light' }})
Vue 3
npm i @file-viewer/vue3-full
import { createApp } from 'vue'import FileViewer from '@file-viewer/vue3-full'createApp(App).use(FileViewer).mount('#app')
<file-viewer url="/files/report.docx" />
Vue 2
npm i @file-viewer/vue2.7-full
# Vue 2.6 Project using @file-viewer/vue2.6-full
import Vue from'vue'
import FileViewer from'@file-viewer/vue2.7-full'
Vue.use(FileViewer)
React
npm i @file-viewer/react-full
import FileViewer from '@file-viewer/react-full'export function Preview() {return <FileViewer url="/files/report.pdf" style={{ height: 720 }} />}
Svelte
npm i @file-viewer/svelte-full
<script>import FileViewer from '@file-viewer/svelte-full'</script><FileViewer url="/files/report.pdf" containerStyle="height:720px" />
jQuery
npm i @file-viewer/jquery-full
import '@file-viewer/jquery-full'$('#viewer').fileViewer({ url: '/files/report.pdf' })
On-demand combination
npm i @file-viewer/vue3 @file-viewer/preset-office
import officePreset from '@file-viewer/preset-office'const options = {preset: officePreset,theme: 'light',toolbar: { position: 'bottom-right' }}
Vite Project can additionally install @file-viewer/vite-plugin, automatically discover installed preset and copy Worker/WASM/fonts/vendor resources; Non-Vite Project directly use options.preset, no need additional plugin.
Architecture
-
@file-viewer/core: Format recognition, resource loading, renderer protocol, lifecycle, search, zoom, print, export, and controller API. -
@file-viewer/renderer-*: PDF, Word, PPTX, CAD, Typst, Archive, Drawing, Data, EDA, etc. independent rendering capabilities. -
@file-viewer/preset-*: lite, office, engineering, all four types of capability combinations. -
@file-viewer/web|vue3|vue2.7|vue2.6|react|react-legacy|svelte|jquery: Native components for each ecosystem. -
@file-viewer/*-full: Component + preset-all one-step package, suitable for rapid verification and all-format attachment center.
6. Source Code Repository
Open-source project address:
https://github.com/flyfish-dev/file-viewer
Next steps