<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[CleverUtils Blog]]></title><description><![CDATA[CleverUtils Blog]]></description><link>https://cleverutils.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 07 Nov 2026 10:23:10 GMT</lastBuildDate><atom:link href="https://cleverutils.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Markdown, DOCX and PDF in a Docs Workflow: What Converts Cleanly and What Breaks]]></title><description><![CDATA[Keep Markdown as the source, treat DOCX and PDF as outputs, and know where conversions lose data]]></description><link>https://cleverutils.hashnode.dev/markdown-docx-and-pdf-in-a-docs-workflow-what-converts-cleanly-and-what-breaks</link><guid isPermaLink="true">https://cleverutils.hashnode.dev/markdown-docx-and-pdf-in-a-docs-workflow-what-converts-cleanly-and-what-breaks</guid><category><![CDATA[documentation]]></category><category><![CDATA[markdown]]></category><category><![CDATA[Pandoc]]></category><category><![CDATA[technical writing]]></category><category><![CDATA[Productivity]]></category><dc:creator><![CDATA[CleverUtils]]></dc:creator><pubDate>Sat, 31 Oct 2026 21:15:29 GMT</pubDate><content:encoded><![CDATA[<p>Most engineering teams write docs in Markdown. Most of the people who read those docs outside the team live in Word and PDF. Product managers send DOCX specs with tracked changes, legal wants a PDF they can attach to a contract, and a customer sends a 40-page PDF manual that somebody now has to turn into a page in the docs repo.</p>
<p>So conversion is part of the job. The trouble is that these three formats were built for different things, and every conversion between them throws something away. This guide covers what each format really stores, which direction converts cleanly, and how to set up a workflow where the losses don't hurt.</p>
<h2>Three formats, three different ideas of a document</h2>
<p><strong>Markdown</strong> is plain text with light structure: headings, lists, links, code blocks, emphasis and (in GitHub Flavored Markdown) tables. It has no concept of page size, fonts or margins. That is why it diffs well in Git and why it is pleasant to review in a pull request.</p>
<p><strong>DOCX</strong> is a ZIP archive of XML files. It stores structure (paragraph styles such as Heading 1), but also direct formatting, comments, tracked changes, headers, footers, section breaks and embedded images. Much of what makes a Word file look right lives in styles and layout settings that Markdown has no place for.</p>
<p><strong>PDF</strong> is a page description format. It records where glyphs and shapes go on a fixed page. A paragraph in a PDF is often just a series of positioned text runs, and a table may be a grid of lines with text placed inside it. Tagged PDFs can carry a logical structure, but plenty of PDFs in the wild don't have one.</p>
<p>Put simply: Markdown stores meaning, PDF stores appearance, and DOCX stores a mix of both. Conversions that go from meaning to appearance work well. Conversions that go from appearance back to meaning involve guessing.</p>
<h2>Markdown as the source of truth</h2>
<p>The workflow that causes the least pain treats Markdown as the only file you edit and generates DOCX and PDF from it when someone needs them. Generated files are build artifacts. You don't commit edits to them and you don't fix typos in them.</p>
<p>Pandoc is the standard tool for this. A few commands cover most needs:</p>
<pre><code class="language-bash"># Markdown to DOCX, using your company template for styles
pandoc guide.md -o guide.docx --reference-doc=company-template.docx

# Markdown to PDF (needs a PDF engine; LaTeX is the default)
pandoc guide.md -o guide.pdf --pdf-engine=xelatex

# Markdown to standalone HTML, which you can then print to PDF
pandoc guide.md -s -o guide.html
</code></pre>
<p>The <code>--reference-doc</code> option is worth knowing. Pandoc maps Markdown headings, body text and code to named Word styles, and takes the look of those styles from the reference document. Fonts, colours and spacing come out matching the corporate template without anyone touching the DOCX by hand.</p>
<p>For PDF, the main decision is the engine. LaTeX engines give good typography but need a large install. HTML-based engines such as WeasyPrint let you style the output with CSS, which many web developers find easier. Either way, run the build in CI so the PDF attached to a release always matches the Markdown in the tag.</p>
<h2>Bringing DOCX into the repo</h2>
<p>Sooner or later someone hands you a Word document that has to become docs. Pandoc handles this direction well, because DOCX keeps real structure underneath the formatting:</p>
<pre><code class="language-bash">pandoc spec.docx -t gfm --wrap=none --extract-media=./media -o spec.md
</code></pre>
<p>What each flag does:</p>
<ul>
<li><code>-t gfm</code> writes GitHub Flavored Markdown, so tables survive as pipe tables where possible.</li>
<li><code>--wrap=none</code> keeps each paragraph on one line, which makes later diffs much cleaner.</li>
<li><code>--extract-media=./media</code> writes embedded images to a folder and links them from the Markdown.</li>
</ul>
<p>If the document has tracked changes, decide what you want before converting. Pandoc's <code>--track-changes</code> option accepts <code>accept</code>, <code>reject</code> or <code>all</code>. Accepting is usually right for a final spec. Keeping all changes is useful when you need to see what a reviewer did.</p>
<p>The usual problems come from authors who formatted by hand instead of using styles. A line made bold and 16pt is not a heading as far as the file is concerned, so it arrives in Markdown as bold text. Merged table cells, text boxes and floating images also have no Markdown equivalent. Expect to spend a few minutes fixing headings and tables after the conversion. Searching the output for <code>**</code> at the start of lines is a quick way to find fake headings.</p>
<h2>Getting text out of PDF without false expectations</h2>
<p>PDF to Markdown is the hardest direction, because the converter has to rebuild structure from layout. It guesses headings from font size and weight, paragraphs from line spacing, and tables from alignment. Multi-column layouts, footnotes, running headers and page numbers all get in the way.</p>
<p>Some practical rules:</p>
<ul>
<li><strong>Find the source first.</strong> If the PDF was exported from Word, Google Docs or a docs site, ask for the original. A DOCX or HTML file will convert far better than the PDF made from it.</li>
<li><strong>Check whether the PDF has a text layer.</strong> Try selecting text in a viewer. If you can't, the file is a scan, and you need OCR before any Markdown conversion means anything.</li>
<li><strong>Treat the output as a draft.</strong> Expect to fix heading levels, rejoin hyphenated words, delete repeated headers and footers, and rebuild complex tables by hand.</li>
<li><strong>Diff, don't trust.</strong> Put the converted Markdown in a branch and read it in the PR view next to the original PDF.</li>
</ul>
<p>For a one-off file where installing a toolchain isn't worth it, a browser converter is the quickest way to get a first draft. The <a href="https://cleverutils.com/pdf-to-markdown">PDF to Markdown converter on CleverUtils</a> runs in the browser, needs no account, and uploaded files are deleted automatically after 2 hours. That still means uploading the file to a server, so keep confidential documents on local tools.</p>
<h2>A workflow that holds up</h2>
<p>Putting it together, a setup that works for small and mid-sized teams looks like this:</p>
<ol>
<li><strong>One source format.</strong> Docs live as Markdown in the repo. Everyone edits there, through pull requests.</li>
<li><strong>Generated outputs.</strong> A CI job builds DOCX (with a reference template) and PDF on every release and attaches them as artifacts. Nobody edits those files.</li>
<li><strong>One-way imports.</strong> When a DOCX or PDF arrives from outside, convert it once, clean it up, commit the Markdown, and archive the original. After that, the Markdown is the document.</li>
<li><strong>Comments come back as Markdown changes.</strong> If a reviewer marks up the DOCX, apply their changes to the Markdown source instead of merging the Word file back.</li>
<li><strong>Images live in a folder.</strong> Keep extracted and new images in a predictable path such as <code>docs/media/</code> and reference them with relative links, so every output format can find them.</li>
</ol>
<p>The point of all this is to never round-trip. Markdown to DOCX and back to Markdown loses something each time, usually in tables and image references, and after a few cycles the source is a mess.</p>
<h2>Quick reference</h2>
<table>
<thead>
<tr>
<th>Conversion</th>
<th>How clean</th>
<th>Main risks</th>
</tr>
</thead>
<tbody><tr>
<td>Markdown to DOCX</td>
<td>Clean</td>
<td>Styling depends on the reference template</td>
</tr>
<tr>
<td>Markdown to PDF</td>
<td>Clean</td>
<td>Needs a PDF engine; page breaks need tuning</td>
</tr>
<tr>
<td>DOCX to Markdown</td>
<td>Mostly clean</td>
<td>Fake headings, merged cells, text boxes</td>
</tr>
<tr>
<td>PDF to DOCX</td>
<td>Mixed</td>
<td>Layout rebuilt from positions; fonts substituted</td>
</tr>
<tr>
<td>PDF to Markdown</td>
<td>Draft quality</td>
<td>Structure guessed; scans need OCR first</td>
</tr>
</tbody></table>
<p>Local tools like Pandoc are the right choice for anything repeatable or sensitive. For the odd file that lands in your inbox in a format you don't have tools for, CleverUtils (<a href="https://cleverutils.com">https://cleverutils.com</a>) has 200+ converters that run in the browser with no account and no watermarks. It is made in Kyiv, Ukraine.</p>
]]></content:encoded></item></channel></rss>