Skip to main content

Office documents

TF Code's files side panel ships built-in, view-only previews of .xlsx, .docx, and .pptx files — no config, no external dependencies. Lazy-loaded parsers do the work: SheetJS renders spreadsheets as tables with sheet tabs, mammoth handles Word, and pptx-preview handles slide decks.

Install LibreOffice and the .docx / .pptx previews upgrade: TF Code converts the document to PDF (headless) and shows it in the same embedded PDF viewer — full-fidelity fonts, layout, and columns that the built-in converters approximate or drop.

An Open in LibreOffice button appears above the preview, so you can edit the document in the desktop app and watch the preview refresh when you save.

tip

The LibreOffice integration is opt-in and disabled by default — TF Code never launches it unless you enable it. The built-in previews work with nothing installed.


Enable​

Turn the integration on in your config:

{
"office": {
"enabled": true
}
}
OptionTypeDefaultDescription
office.enabledbooleanfalseTurns the integration on. Opt-in — TF Code never launches LibreOffice unless this is set.
office.pathstringauto-detectExplicit path to the soffice binary. Only needed if auto-detection can't find it.

Set it in global or project tfcode.json — the same merge rules apply as everywhere else.

warning

After changing the config, reload or restart the app so it picks it up.


Find LibreOffice​

When office.path is not set, TF Code auto-detects the soffice binary in this order:

  1. soffice on the PATH
  2. Platform default locations:
PlatformDefault locations
macOS/Applications/LibreOffice.app/Contents/MacOS/soffice (and the same under ~/Applications)
Linux/usr/bin/soffice, /usr/bin/libreoffice, /usr/local/bin/soffice, /opt/libreoffice/program/soffice
WindowsC:\Program Files\LibreOffice\program\soffice.exe (and the Program Files (x86) equivalent)
tip

On macOS, brew install --cask libreoffice lands in the auto-detected location — no office.path needed.

If an explicit office.path is set but doesn't exist, the integration reports unavailable rather than silently falling back.


View and edit​

With the integration on, .docx and .pptx previews are converted to PDF and rendered in the embedded PDF viewer — fonts, layout, and columns match the original. An Open in LibreOffice button appears above the preview.

Click it to open the document in the LibreOffice desktop app and edit for real. When you save, TF Code's file watcher detects the change and the in-app preview refreshes automatically — the full view/edit round trip.

.xlsx keeps the built-in table view by design: a table is more useful for data than a paginated PDF, and it supports sheet tabs. The Open in LibreOffice button still opens spreadsheets in the desktop app.

tip

Everything is strictly additive. If the integration is disabled, LibreOffice is missing, a conversion fails or times out, or the file is too large, the preview silently falls back to the built-in native previews — you never get a broken preview. In-flight conversions show a Converting … with LibreOffice status.


Know the limits​

GuardBehaviour
FormatsOnly .docx, .xlsx, and .pptx — legacy .doc, .xls, and .ppt are not supported.
Source sizeFiles above 50 MB are not converted (falls back to the built-in preview, which itself caps at 5 MB).
Zip bombsThe archive's central directory is checked before LibreOffice ever runs — max ~250 MB uncompressed, max 10,000 entries.
CachingConversions are cached on disk, keyed by path + mtime + size. An unchanged file re-previews instantly; any edit — from TF Code or LibreOffice — invalidates it automatically.
ConcurrencyConversions run serialized, with a 30-second timeout each.
Cache sizeBest-effort cap of ~200 MB — the oldest conversions are pruned first.
ContainmentOnly files inside the current project directory are converted or opened; symlinks pointing outside the project are rejected — the same containment rules as the rest of TF Code's file access.

Call the API​

For advanced use, the server exposes two endpoints:

EndpointDescription
GET /office/preview?path=<project-relative>Convert an office document to PDF. Returns a base64 PDF as FileContent JSON.
POST /office/openOpen a document in the LibreOffice desktop app. Body: {"path": "..."}.

Error mapping:

StatusMeaning
403Path outside the project, or an untrusted cross-origin request.
413File too large.
500Conversion failed or timed out.
503Integration disabled or LibreOffice not found.

Stay local​

TF Code detects and launches your own LibreOffice installation — nothing is bundled, vendored, or downloaded. Conversion is fully local: no document ever leaves your machine.


  • Config — global vs project tfcode.json and merge rules
  • Web app — the session UI and file panel where previews live
  • Server Mode — how clients attach to a running server