DEXT-PDF · DEXT-OCR
📗 Editor manual

External Module Integration Guide — DEXT-PDF · DEXT-OCR

This guide explains how to attach the separate products DEXT-PDF and DEXT-OCR to Dee Editor to extend PDF import and add text recognition. For all editor options and methods, see the Dee Editor manual.

1. Overview

External modules are separate products that are not part of the Dee Editor bundle. The editor provides only a connector plugin for each module; place the module folder in the expected location and the plugin finds and loads it the first time it is used. Without the module the editor works as before and only hides, or falls back from, the features that need it.

1-1. Components

ElementMeaning
DEXT-PDFRefers to the PDF structure-analysis and viewer product. It extends PDF import to Type 2 (structure analysis, text highlights, real progress and cancel); in the sample board it also handles attachment preview, page editing and merging.
DEXT-OCRRefers to the text recognition engine that runs in the browser. It reads printed Korean and English in scanned documents, photos and scanned PDFs and inserts them into the body as paragraphs and tables.
Connector pluginRefers to the editor-side plugin: pdfimport (dist/plugins/pdfimport-native.min.js) for DEXT-PDF and ocr (dist/plugins/ocr-native.min.js) for DEXT-OCR.
AdapterRefers to the part of the plugin that finds and loads the module and wraps it in the form the editor uses. You do not write any code for it.

1-2. Common rules

Both modules attach by the same rules. Once you have attached one, the other works the same way.

RuleDescription
Place beside the bundlePut the module folder next to the editor's dist/ folder (same parent folder) and the plugin finds it automatically. To place it elsewhere, give its location in an editor option or a global path.
Load on first useThe module is loaded with import() the first time the feature is used. It does not affect editor start-up or bundle size.
Check before loadingWhen no location is given, the plugin first checks with a HEAD request that the file exists at the expected place, so a missing module does not leave errors in the console.
Fall back when absentWithout DEXT-PDF, PDF import uses the built-in engine (Type 1). Without DEXT-OCR, the text recognition items are hidden.
In-browser processingBoth modules convert and recognize inside the user's browser. Files and images are not sent to a server, so they work on closed networks too.

Common setup example

<script src="dist/webeditor.min.js"></script>
<script src="dist/plugins/pdfimport-native.min.js"></script>   <!-- DEXT-PDF connector -->
<script src="dist/plugins/ocr-native.min.js"></script>         <!-- DEXT-OCR connector -->
<script>
  const editor = new WebEditor('#editor', {
    plugins: [ /* default plugins */ 'pdfimport', 'ocr' ]
  });
</script>

With this code, placing the dext-pdf/ and dext-ocr/ folders next to dist/ completes the integration. See 4-1 for the folder layout.

2. DEXT-PDF integration

Overview

Dee Editor's PDF import (pdfimport) has two engines. Type 1 is the built-in parser; Type 2 uses the structure analysis of the DEXT-PDF runtime. With DEXT-PDF attached, tagged PDFs keep their structure, and you get text highlights, underline and strikeout, vector shapes and charts as images, and real progress with mid-way cancel. For PDF import itself, see 9-J in the editor manual.

2-1. Components

ElementMeaning
dext-pdf/dext-pdf.jsRefers to the DEXT-PDF runtime (ES module). It includes PDF.js and its worker; PDF import uses its openDocument.
dext-pdf/wasm/Refers to the JBIG2 and JPEG2000 image decoders and colour management.
dext-pdf/cmaps/Refers to the CID font maps (including Adobe-Korea1). Without them, text in Korean CID-font PDFs is garbled.
dext-pdf/standard_fonts/Refers to the substitutes for the 14 standard PDF fonts.
DextPdfSource · DextStructureSourceRefers to the adapters inside the pdfimport plugin. They find and load the runtime and pick the structure path or the fragment path depending on its version (2-5).
The three asset folders (wasm/, cmaps/, standard_fonts/) are not optional. Without them scanned pages come out blank or Korean text is garbled, and both happen without any error. Copy the folder as a whole.

2-2. Placement · lookup order

The runtime is looked for in the order below. When no location is given, the two places next to the bundle are checked in turn.

OrderLocation
1Editor option pdfImport.dextPdfUrl — the address of dext-pdf.js or of its folder. A folder gets dext-pdf.js appended.
2Global WebEditor.dextPdfPath
3../dext-pdf/dext-pdf.js relative to the bundle
4../dext-pdf-viewer/dext-pdf.js relative to the bundle

Location example

// Per editor — with the option
new WebEditor('#editor', {
  plugins: ['pdfimport'],
  pdfImport: { dextPdfUrl: '/static/dext-pdf/dext-pdf.js' }
});

// Site-wide — once, before creating editors
WebEditor.dextPdfPath = '/static/dext-pdf/';

A location you give explicitly is loaded directly without the HEAD check; if it fails, a warning ([PdfImport] DEXT-PDF load failed) is written to the console. If an old runtime without openDocument (0.2.0 or earlier) is found, Type 1 is used.

2-3. Choosing the engine

The engine can be set in three places. If none is set, 'auto' applies: Type 2 when the runtime is present, otherwise Type 1.

ParameterDescription
'auto' ('both')Refers to the default: Type 2 when the runtime is present, otherwise Type 1. You can switch between the two under "Conversion engine" in the import dialog to compare.
'native' ('type1')Refers to using the built-in engine only. Type 2 is not offered in the dialog.
'dext-pdf' ('type2')Refers to using DEXT-PDF only. If the runtime is not found, it reports an error instead of falling back to Type 1, so a configuration mistake is not hidden.

Engine selection example

// Site-wide — webeditor-configuration.js (loaded before the bundle)
window.WebEditorPdfImportEngine = 'both';     // 'type1' · 'type2' · 'both'

// Per editor
new WebEditor('#editor', { plugins: ['pdfimport'], pdfImport: { engine: 'auto' } });

// Per call
await editor.importPdfFile(file, { engine: 'dext-pdf' });

Precedence: the engine of importPdfFile > the editor option pdfImport.engine > the global setting window.WebEditorPdfImportEngine > 'auto'.

2-4. Options

Editor option pdfImport

PDF import defaults given when the editor is created. The dialog's initial choices follow them too.

ParameterDescription
engineRefers to the conversion engine: 'auto' (default), 'native' or 'dext-pdf' (2-3).
dextPdfUrlRefers to the location of the DEXT-PDF runtime (2-2).
modeRefers to the default import method: 'auto' (default), 'text' or 'image'.
pageBreaksRefers to whether a page break is inserted at page boundaries. Default false; when off, paragraphs split across pages are joined.
headerFooterRefers to whether headers, footers and page numbers repeated on every page are removed. Default true.

importPdfFile(file, options) options

ParameterDescription
engineRefers to the engine for this call. It takes precedence over the editor option.
importModeRefers to the import method: 'auto' brings text pages in as body content and scanned pages as images, 'text' takes text only, and 'image' brings each page in as one image. Bringing every page in as an image works without restriction in Type 2.
modeRefers to the insert mode: 'cursor', 'append' or 'replace'.
silent · showLogRefers to skipping the dialog and to showing all conversion warnings.
pagesRefers to an array of page numbers to import (1-based). All pages when omitted.
passwordRefers to the open password. When omitted, it is asked for when needed.

Import from code example

const file = document.querySelector('#pdf').files[0];
await editor.importPdfFile(file, {
  silent: true,            // no dialog
  mode: 'cursor',          // at the cursor
  engine: 'auto',          // Type 2 when DEXT-PDF is present
  pages: [1, 2, 3]
});

The unified "Import document" button, drag and drop, and [File] › Import PDF in the menu all take the same path without extra code.

2-5. Features by version

What Type 2 can do depends on the version of the DEXT-PDF runtime placed alongside. The adapter checks the runtime's capabilities and picks the path it can use, so there is nothing to configure.

DEXT-PDF versionDescription
0.2.0 or earlierRefers to versions without openDocument, which cannot be used for Type 2. Type 1 is used.
0.3.0 or laterRefers to the fragment path: the runtime supplies text fragments and Dee builds paragraphs and tables.
0.4.1 or laterRefers to the structure path: the runtime builds the document structure (getStructures). Header clean-up, joining across pages, document-wide heading levels and nested lists come from here.
0.4.2 or laterRefers to real progress and mid-way cancel (onProgress · signal).
0.4.8 or laterRefers to the certificate and form improvements (dropping the faint background seal, splitting label lines).
The sample board (JSP) and the internal demos ship DEXT-PDF 0.5.3. To upgrade, replace the whole dext-pdf/ folder.

2-6. Server settings

ItemDescription
Static pathServe the dext-pdf/ folder as static files. No separate server program is needed.
MIMEServe .js as text/javascript, .wasm as application/wasm, and .bcmap (CID maps) and .pfb (standard fonts) as application/octet-stream; the samples in deploy/ include them. If .js arrives with another type, the browser refuses the module.
HEAD requestsWhen no location is given, the plugin checks with HEAD. If your server blocks HEAD, give the location with pdfImport.dextPdfUrl.
CachingThe adapter adds the ETag or Last-Modified of the HEAD response to the load address, so a replaced runtime file is fetched fresh. To refresh the worker fragments the runtime loads by itself as well, send Cache-Control: no-cache for /dext-pdf/ (as the sample board does).

2-7. PDF preview

The same dext-pdf/ folder also works as a viewer for attached PDFs through the <dext-pdf-editor> element. The viewer is set up separately from Dee Editor; the editor itself is not involved.

Viewer setup example

<script>
  window.DEXT_PDF_CONFIG = { lang: 'en', zoom: 'fit-page' };   // before the module
</script>
<script type="module" src="/dext-pdf/dext-pdf.js"></script>
<dext-pdf-editor src="/attach/download?v=1"></dext-pdf-editor>

The global setting window.DEXT_PDF_CONFIG must be defined before the module. For server-side features such as rotating, deleting and merging pages, and for choosing between the approaches, see 14-6 in the editor manual.

3. DEXT-OCR integration

Overview

DEXT-OCR is a text recognition engine that reads printed Korean and English in scanned documents, photos and scanned PDFs. Recognition runs inside the user's browser (WebAssembly and workers); images are not sent to a server. The editor provides only the connector plugin ocr; the engine is supplied as a separate package (dext-ocr-v<version>-dee-editor.zip) to customers who request it. Results are inserted at the cursor page by page as paragraphs and tables; tables become editor tables, so cell editing, merging and borders work as usual.

3-1. Components

ElementMeaning
dist/plugins/ocr-native.min.jsRefers to the connector plugin (opt-in, about 43 KB). It contains no engine or models.
dext-ocr/src/index.jsRefers to the engine entry module. The plugin loads it with import() on first use and calls loadOcr({ baseUrl }) once.
dext-ocr/models/ · dext-ocr/vendor/Refers to the recognition models (.onnx), the runtime (WebAssembly) and pdf.js. The whole engine is about 23 MB; the first use downloads about 8–9 MB compressed.
DextOcrSourceRefers to the built-in adapter in the plugin. It wraps the engine in the OCR contract (OcrProvider v1.1); its name in the editor is 'dext-ocr'.

3-2. Placement · lookup order

Copy the package's dext-ocr/ folder next to dist/. The engine is looked for in the order below; a folder address gets src/index.js appended.

OrderLocation
1Editor option ocr.dextOcrUrl — a folder (/dext-ocr/) or …/src/index.js
2Global WebEditor.dextOcrPath
3../dext-ocr/ relative to the bundle
Setting false in any of these — ocr.dextOcrUrl: false, WebEditor.dextOcrPath = false, or window.WebEditorDextOcrPath = false before the core bundle — stops the lookup (v2.7.0.0): no request is made, no 404 appears in the console, and the text recognition items are hidden. Engines registered with registerOcrProvider still work. Packages shipped without the engine set this in their demo settings; delete that line after adding dext-ocr/.

Setup example

<script src="dist/webeditor.min.js"></script>
<script src="dist/plugins/ocr-native.min.js"></script>
<script>
  const editor = new WebEditor('#editor', {
    plugins: [ /* default plugins */ 'pdfimport', 'ocr' ],
    ocr: { dextOcrUrl: '/static/dext-ocr/' }     // omit if placed next to dist/
  });
</script>

The engine is loaded only once per page. Even with several editors on one page, it is downloaded once.

If the engine is not found or the browser is not supported, the text recognition items on the toolbar, menu and ribbon are hidden (ocr.hideWhenNoProvider). Called from code anyway, it shows "not installed" and the Promise is rejected with the error code 'OCR_NOT_INSTALLED'.

3-3. Entry points

Entry pointDescription
Toolbar · [File] menu · [File] ribbon — Text recognitionRefers to choosing an image (JPG, PNG, WebP …) or a scanned PDF and inserting it at the cursor page by page. The progress window appears in the middle of the document body, and the body is locked read-only until recognition ends (the toolbar and menus are disabled too). You can cancel from the progress window (Esc); pages already inserted remain.
Import documentRefers to choosing image files in the unified "Import document" when the engine is present; the chosen image is read and inserted as text.
Right-click an image — Extract text from imageRefers to showing the recognized text in an editable window. Choose [Insert into body], [Use as alt text] or [Copy].
Scanned pages from PDF importRefers to offering [Convert to text] after scanned pages without text were inserted as images. This works most naturally with DEXT-PDF and DEXT-OCR attached together.

Undo goes back one page at a time. Nothing is inserted into a read-only document.

3-4. API · events

APIDescription
editor.ocrInsert(file, { output, signal, privacy })Reads an image or scanned PDF and inserts it at the cursor. Returns Promise<{ text, html, pages, cancelled }>; when cancelled it resolves with cancelled: true. Passing privacy overrides the ocr.privacy option for that call only (e.g. { privacy: { rrn: 'back' } } — extractTextFromImage takes it too).
editor.extractTextFromImage(input, { insert, output, signal, onProgress })Returns the recognition result only. insert is 'none' (default), 'body' (at the cursor), 'clipboard' or 'alt' (as alt text when the input is an <img> in the body).
WebEditor.registerOcrProvider(adapter, { default })Registers another engine (3-7).
editor.setOcrProvider(name) · editor.getOcrProviders()Selects an engine and lists engines when there are several. Registered engines come first, then DEXT-OCR ('dext-ocr').
EventDescription
ocrStartRefers to the start of recognition. Argument: { file, provider }.
ocrProgressRefers to progress. Argument: { fraction, info: { stage, pageNo, pageCount } }.
ocrPageRefers to each page being inserted into the body. Argument: { pageNo, text }.
ocrDone · ocrCancel · ocrErrorRefers to completion, cancellation and error. Arguments: { pages, text }, { pages } and { error }.

Recognition from code example

const ctrl = new AbortController();
editor.on('ocrProgress', (e) => bar.value = e.fraction);
editor.on('ocrPage', (e) => console.log('inserted page ' + e.pageNo));

try {
  const result = await editor.ocrInsert(file, { signal: ctrl.signal });
  if (!result.cancelled) console.log(result.pages.length + ' page(s) done');
} catch (e) {
  if (e.code === 'OCR_NOT_INSTALLED') alert('The text recognition engine is not installed.');
}

// Result only — fill another field without touching the body
const r = await editor.extractTextFromImage(file, { output: 'text' });
document.querySelector('#summary').value = r.text;

Calling ctrl.abort() stops recognition; pages inserted up to that point stay in the body.

3-5. Options

Set with the editor option ocr. All are optional.

ParameterDescription
dextOcrUrlRefers to the engine location (3-2). Automatic when omitted; false means do not look for it.
outputRefers to what is inserted: 'full' (default — paragraphs and tables) or 'text' (a paragraph per line, table cells joined with spaces).
hideWhenNoProviderRefers to hiding the items when there is no engine. Default true.
privacyRefers to how the engine masks resident registration numbers before inserting: { rrn: 'back' | 'gender' | 'all' | false }, default false.
htmlRefers to table HTML options, e.g. { headerRow: true } to make the first row header cells.
ocrOptionsRefers to DEXT-OCR recognition options (pre, det, rec, layout). See docs/API.md in the engine package.

Options example

new WebEditor('#editor', {
  plugins: [ /* default plugins */ 'ocr' ],
  privacy: true,                          // personal-data notice after inserting
  ocr: {
    output: 'full',
    privacy: { rrn: 'back' },               // insert as 800101-*******
    html: { headerRow: true }
  }
});

With the editor option privacy (personal data detection) on, a notice with [Review] appears when the inserted content contains resident registration, phone or account numbers. To mask in the engine before inserting, add ocr.privacy.rrn.

3-6. Server · browsers

ItemDescription
MIMEServe .mjs as text/javascript, .wasm as application/wasm and .onnx as application/octet-stream. They are set in the sample board's (JSP) web.xml.
IISIIS refuses any extension without a registered MIME type with 404.3 (a plain 404 in the browser). Engine 0.2.0's .mjs (engine module, onnxruntime) and .onnx (recognition models) are not in the default list, so without them text recognition stops with "Could not download the recognition engine". As in deploy/iis/web.config, put <remove> before each <mimeMap> (a duplicate entry without it stops the whole site with 500.19). For merging into an existing web.config, request filtering and the URLs to check, see "Text recognition (DEXT-OCR) setup notes (IIS)" in DEPLOY.md.
CSPPages with a security policy need 'wasm-unsafe-eval' in script-src and 'self' in worker-src. Otherwise the editor reports that a security policy (CSP) blocked the recognition engine.
Compressiondocs/deploy.md in the engine package shows how to serve the pre-compressed .br and .gz files on Tomcat, nginx, Apache and IIS. It works without it; on Tomcat 7, put Apache in front and use the Apache settings.
CachingThe engine rarely changes; serve it from a versioned folder (/dext-ocr/0.2.0/) with long caching and it is not downloaded again.
BrowsersChrome · Edge 91 or later on PC, Chrome and Samsung Internet on Android, and Safari 16.4 or later on iOS and macOS. Support is decided by the engine (checkSupport — WebAssembly SIMD, module workers and so on) before any model is downloaded; in unsupported browsers (such as Internet Explorer) the items are hidden.
PhonesOn phone browsers the same engine runs in a worker, so the screen does not freeze (measured on Android Chrome: a scanned table document in 3–5 s, an A4 photo taken by hand in about 10 s). Photos are flattened and their lighting corrected automatically. For PDFs only the pdf.js build that suits the browser is downloaded (vendor/pdfjs/legacy/ for older browsers).
Apps (WebView)Inside an app that includes the DEXT-OCR Android or iOS library, the app's native engine (window.DextOcrNative) is used automatically and no WASM, models or pdf.js are downloaded. The editor setup is the same.

CSP example

Content-Security-Policy: script-src 'self' 'wasm-unsafe-eval'; worker-src 'self'

3-7. Other engines

To use an in-house recognition server or a cloud recognition service instead of DEXT-OCR, write an adapter and register it. The adapter follows the OCR contract OcrProvider v1.1; only name and recognize are required.

ParameterDescription
nameRefers to the engine identifier, e.g. 'server' or 'clova'.
acceptsRefers to the file types offered in the file picker, e.g. ['image/*', 'application/pdf'].
init(onProgress)Refers to a preparation function called once on first use (optional).
recognize(input, opts)Refers to the recognition function (required). It returns Promise<{ text, html?, pages? }> and rejects with name === 'AbortError' when cancelled through opts.signal.
opts.onPageRefers to a callback per finished page; when the engine calls it, the editor inserts each page right away. Otherwise the editor inserts pages → html → text after recognition ends.
dispose()Refers to a function that releases resources (optional).

In-house server adapter example

WebEditor.registerOcrProvider({
  name: 'server',
  accepts: ['image/*'],
  async recognize(input, opts = {}) {
    const fd = new FormData();
    fd.append('file', input);
    const res = await fetch('/api/ocr', { method: 'POST', body: fd, signal: opts.signal });
    const data = await res.json();
    return { text: data.text };              // text only → one paragraph per line
  }
}, { default: true });

Register once, before creating editors. An engine registered with { default: true } is used before DEXT-OCR, and the editor sanitizes any html it returns before inserting (removing scripts, on* attributes and javascript:).

With a cloud recognition service, images are sent outside. Users must be told, and it cannot be used on closed networks. DEXT-OCR and in-house servers send nothing outside.

3-8. Limitations

  • Results can differ from the original. For documents that must be exact, such as official letters and contracts, compare with the original after inserting.
  • Handwriting, vertical writing and very small text (6 pt or less) are not read well.
  • The first use takes time because the engine is downloaded. After that it starts right away from the browser cache.

4. Deployment · checks

4-1. Folder layout

With the three folders under the same parent folder, no location options are needed.

/editor/
├─ dist/
│   ├─ webeditor.min.js
│   └─ plugins/
│       ├─ pdfimport-native.min.js     PDF import (DEXT-PDF connector)
│       └─ ocr-native.min.js           Text recognition (DEXT-OCR connector)
├─ dext-pdf/                           DEXT-PDF runtime — the whole folder
│   ├─ dext-pdf.js
│   ├─ wasm/ · cmaps/ · standard_fonts/
│   └─ THIRD-PARTY-NOTICES.txt
└─ dext-ocr/                           DEXT-OCR engine — the whole folder
    ├─ src/index.js
    ├─ models/ · vendor/
    ├─ LICENSES/
    └─ THIRD_PARTY_NOTICES.txt
ElementMeaning
DEXT-PDF supplyRefers to the runtime folder from the DEXT-PDF product package. The sample board and internal demos contain 0.5.3.
Enterprise packageRefers to dee-editor-v<version>-Enterprise.zip. It contains dext-pdf/ and dext-ocr/ next to dist/, so both modules work once the package is deployed as it is.
DEXT-OCR supplyRefers to the separate package dext-ocr-v<version>-dee-editor.zip for customers who request it. It contains dext-ocr/, INSTALL.txt, docs/deploy.md, docs/API.md and the license texts.

4-2. Sample board

The JSP sample board includes both modules, so you can see the integration working right away.

ElementMeaning
webapp/dext-pdf/Refers to DEXT-PDF, which handles attachment PDF preview, page editing and merging, and PDF import Type 2 when writing posts.
webapp/dext-ocr/Refers to DEXT-OCR, which handles the [Text recognition] toolbar button and the image right-click [Extract text from image] when writing posts. It is included by default; pass --no-ocr when building the package to leave it out.
web.xmlRefers to where the .mjs, .wasm and .onnx MIME types are set. Use it as a reference when moving to another web app.
EncodingFilterRefers to the filter that adds Cache-Control: no-cache to product folders such as /dext-pdf/, so a replaced runtime never leaves stale files behind.

The basic board (the edition with Dee Editor and DEXT Image only) does not include DEXT-PDF, so its PDF import uses the built-in engine (Type 1). For the board setup in detail, see chapter 14 of the editor manual.

4-3. License notices

Both modules include open-source software. When deploying to customer systems, the notice files must be redistributed with them.

ParameterDescription
dext-pdf/THIRD-PARTY-NOTICES.txt · dext-pdf/wasm/LICENSE_*Refers to the notices for PDF.js and other components in DEXT-PDF.
dext-ocr/THIRD_PARTY_NOTICES.txt · dext-ocr/LICENSES/Refers to the notices and full license texts for the recognition models, the runtime and pdf.js in DEXT-OCR.
Copying the folders as a whole carries the notice files along. If you copy selected files to save space, make sure the notice files are not left out.

4-4. Checklist

SymptomWhat to check
The PDF import dialog does not offer Type 2Check that dext-pdf/dext-pdf.js is next to dist/, or that pdfImport.dextPdfUrl is given if it is elsewhere. Also check that the global setting is not 'type1'.
"DEXT-PDF runtime not found" errorThe engine is fixed to 'dext-pdf' ('type2') but the runtime was not found. Correct the location or change it to 'auto'.
Korean text in a PDF is garbled, or scanned pages are blankCheck that cmaps/, wasm/ and standard_fonts/ are present in dext-pdf/.
The old behavior remains after replacing the runtimeIt is the browser cache. Send Cache-Control: no-cache for /dext-pdf/ and do a hard refresh.
The text recognition button does not appearCheck that ocr-native.min.js is loaded and 'ocr' is in plugins, that dext-ocr/src/index.js exists, and that the browser is supported.
Text recognition does not startIn the browser's developer tools, check the response type (MIME) of .mjs, .wasm and .onnx on the Network tab.
Only on IIS: "Could not download the recognition engine"If .mjs and .onnx return 404, IIS has no MIME type for them (404.3). Register both in web.config (3-6). Check that dext-ocr/vendor/ort/ort.wasm.min.mjs and dext-ocr/models/det.fp16.onnx return 200.
A message says a security policy (CSP) blocked the engineAdd script-src 'wasm-unsafe-eval' and worker-src 'self' (3-6).
The first recognition takes longThis is normal: the engine (about 8–9 MB compressed) is downloaded on first use. Compression and long caching shorten it.