TroubleshootingDocument
Answers to common problems with Birch UI Document Editor: page counts, fonts, pasted content, DOCX round trips, PDF output, collaboration and console messages.
The page count differs from Word#
Pagination is measured in the browser with the fonts the browser has. If the document uses a font that is not available, the browser substitutes one with different widths, lines break in other places and pages move. Serve the fonts of your templates as web fonts, wait for document.fonts.ready, then call editor.relayout(). See Limitations for layout features that are approximated.
getPageCount() returns a number that changes after loading#
Long documents are laid out in the background. Wait for await editor.whenLayoutReady() or listen for layoutComplete before you use the page count, getPageInfo, getPrintHtml or exportPdf.
The editor has no height or shows only a few lines#
The editor fills its container (height: 100%, with a minimum of 480 px). Give the container a height, or pass height: 720 or height: '80vh'.
Text in the exported PDF looks different from the screen#
Without registered fonts exportPdf uses Helvetica, Times and Courier and scales each word to its on-screen width. Register the real fonts with pdfFonts, or print through the browser. Characters outside Windows-1252 always need a font file: registered, returned by fontLoader or read from the computer. TrueType and OpenType fonts with CFF outlines are embedded; WOFF, WOFF2 and CFF2 files are not read. See PDF export and print.
exportPdf rejects with "PDF export needs the page layout"#
Switch to the page layout first: editor.setLayout('page').
A footnote does not appear at the bottom of the page#
Footnotes are set at the bottom of the page in the page layout. A footnote from a list item or a table cell is set at the bottom of the page that holds that item or row. If the note area is still empty straight after loading, the layout has not finished: wait for whenLayoutReady().
Something is missing after opening a DOCX file#
readDocx(bytes) returns a report with three lists, modelled, preserved and dropped, and warnings. Content that is preserved is not editable but is written back on export. validateDocxPackage(bytes) checks a file the editor wrote. See DOCX import and export.
Word reports a problem with an exported file#
Run validateDocxPackage on the file and look at issues. If it reports none, send us the file: the export is validated against LibreOffice and python-docx and has not yet been validated against Microsoft Word itself.
Lists pasted from Word arrive as indented paragraphs#
Word's clipboard format describes lists as styled paragraphs. The paste clean-up turns them back into nested lists when the clipboard carries Word's HTML and the paste mode keeps formatting. They stay paragraphs when the source put only plain text on the clipboard or the paste mode is Keep text only. Open the .docx file with importDocx when a paste loses structure.
A picture pasted from Word is empty#
Word puts a file:// path to a temporary file on the clipboard, which a web page may not read. The picture arrives as an empty picture with its alternative text and size, and no request is made. Set resolvePastedImage to supply the picture from the RTF on the same clipboard, as described under Pasting from Word and Google Docs, or copy the picture on its own, which pastes it as a file. A picture pasted from Google Docs has an https address and is shown once allowRemoteImages or resolveImage is set.
Pasted text shows tracked changes from another author#
With Keep source formatting, the insertions and deletions that Word tracked are pasted as tracked changes with their original author and time. Accept or reject them in the Review tab, or switch the paste to Merge formatting in the paste options, which keeps the inserted text and drops the deleted text. defaultPasteMode: 'mergeFormatting' does that for every paste.
Comments are missing after a paste from Word#
A paste removes Word's comment anchors and its comment list and keeps the commented text. Open the .docx file with importDocx to bring the comments along.
Collaboration shows desynced#
A remote batch could not be applied to the local document. Send a snapshot through the provider's onReset, or call editor.resetCollab({ document, version }). Make sure every client starts from the same document at the same version and that the server only accepts a batch whose version equals the length of its step log.
"No license key is set" in the console#
Pass licenseKey, or call setLicenseKey from @birchui/license once. The editor keeps working without a key; a watermark is shown on non-local hosts.
"the document content is invalid and was replaced with an empty document"#
content or setJSON received JSON that does not match the schema; the message names the node. A document needs at least one block: { type: 'doc', content: [{ type: 'paragraph' }] }.
Spell checking#
The editor uses the browser's spell checker (spellcheck: true). It has no engine of its own, so languages, suggestions and custom dictionaries are those of the browser. To use your own service or dictionary, pass a function as spellcheck; see Editing.
A Word shortcut opens a browser tab or does nothing#
The browser keeps some combinations for itself (Ctrl+T, Ctrl+Shift+T, Ctrl+Shift+N, Ctrl+N, Ctrl+W in Chrome and Firefox on Windows and Linux) and a page cannot override them. Use the ribbon or exec for those commands; see Keyboard.
Text does not wrap on both sides of a picture#
Both sides are used for square, tight and through wrapping in the page layout, and only when each side is at least 72 px wide. A picture aligned left or right has text on one side. See Tables and images.
The Chart button is missing#
It is shown only when the chartProvider option has a create function. exec('editChart') returns false for a picture that was not inserted through the provider, and for a chart that came back from a DOCX file, which keeps only the picture.