Skip to content

feat: embed local images in DOCX export as base64 #18

@tsdavies

Description

@tsdavies

Summary

DOCX export currently rewrites local-img:// URLs to file:// paths, but html-docx-js only embeds images that use data: base64 URIs. Local images are dropped from the exported document.

Fix

In the export-docx IPC handler in main.ts, before passing HTML to html-docx-js:

  1. Find all file:// image src attributes
  2. Read each file with fs.readFileSync()
  3. Convert to base64: data:image/<ext>;base64,<data>
  4. Replace the src attribute

The library's own test suite demonstrates this pattern works correctly.

Priority

Medium — tracked for v1.6.1

Related

Part of issue #11 (export to HTML and DOCX)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions