Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Word documents as input

A .docx or .doc file is an input like a PDF (kakemono convert report.docx -o report.md): the format is recognised from the file’s bytes. A Word document says what each paragraph is, so it is read directly, without the layout analysis a PDF needs, and turned into the same structure:

  • paragraph styles give the title, authors, abstract, headings (Heading 1–9, or any style with an outline level), captions, footnotes written as paragraphs, references (Bibliography, or the paragraphs after a “References” heading), code (a code style, or text all in a monospaced font) and table of contents entries; list numbering gives list items with their markers (“1.”, “(a)”);
  • Word equations (Office Math) keep their structure: MathML, LaTeX and Office Math in the outputs, in running text too;
  • tables become rebuilt tables (merged cells kept), pictures (PNG, JPEG, GIF, BMP, TIFF, WebP, SVG) figures, with the caption before or after them; footnotes and endnotes follow their paragraph;
  • hyperlinks, cross-references to bookmarks, citations and references to figures and tables become links, as for a PDF;
  • pictures stored as Windows metafiles (EMF, WMF: charts, older drawings) are drawn by kakemono as SVG; they and SVG pictures (the SVG Word keeps beside a PNG too) stay vector in every output: an <img> of the SVG in HTML, an .svg file in Markdown, JSON and EPUB, a PDF picture in LaTeX, an SVG with a PNG beside it in Word, vector drawing in the PDF. An SVG is written again by kakemono first, with only its drawing (no script, link or style sheet);
  • charts of .docx files are drawn by kakemono as SVG (vector in the PDF too), each followed by a table of its data; an Office 2016 chart (waterfall, treemap, …) shows the picture Word keeps beside it, else its data; the charts of .doc files are left out;
  • formulas made with the Equation Editor 3.0 or MathType (MTEF 3 and 5, in .doc and .docx files) become real formulas, floating shapes and text boxes of .doc files are read, and nested lists keep their level.

Pages as Word lays them out. kakemono also lays a Word document out in pages itself, the way Word does: fonts with Word’s metrics (a table of metrics for the usual Office fonts is built in), line breaking, line spacing, widow and orphan control, keep-with-next, tables (row heights, merged cells, borders, shading, repeated header rows), headers and footers, footnotes, sections and columns, frames, floating pictures, shapes and text boxes. No Word, LibreOffice or other program is used. That layout gives:

  • -o report.pdf (or -f pdf): a PDF of the document, with selectable text and links;
  • hard and hard-95: its pages, as for a PDF;
  • medium: Word’s formatting (fonts, colours, indents, spacing, tables, pictures) in one continuous page, without page breaks;
  • friendly stays the single-column article, from the document’s structure.

How close it is to Word is measured in CI on 524 documents with the PDF Word made of them (government reports, forms, letters, guidance, templates; .docx and .doc; see Testing): about 96% of lines break at the same words as in Word, and 89% of documents have the same number of pages. Text edited with --content reaches every output except the page layout (PDF, hard, hard-95, medium). .doc files (Word 97–2003) are read by kakemono itself; Word 6/95 files, RTF files and password-protected files are not. Comments, tracked changes (read as accepted), macros and form fields are not shown. See docs/WORD-INPUT.md for the design.