# Convert Markdown to PDF / DOCX in Devonthink using Pandoc

**URL:** https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764
**Category:** Automation
**Created:** [March 16, 2019, 11:03pm UTC](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764 "2019-03-16T23:03:20Z")
**Posts on this page:** 20
**Page:** 3

<div class="post-metadata">

### Author: ![tja](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/tja/32/7004_2.png) [@tja](https://discourse.devontechnologies.com/u/tja)
#### Post date: [February 18, 2021, 5:55pm UTC](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764/41 "2021-02-18T17:55:37Z")

</div>

An absolute fantastic topic!

I tried to download the zip and the converted examples, but only get some “access denied” messages.

Is this only me, or some general problem?

---

<div class="post-metadata">

### Author: ![eboehnisch](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/eboehnisch/32/38699_2.png) [@eboehnisch](https://discourse.devontechnologies.com/u/eboehnisch)
#### Post date: [February 19, 2021, 4:26pm UTC](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764/42 "2021-02-19T16:26:00Z")

</div>

We have corrected the access permissions for a few affected files in the backend. You should now be able to download them again.

---

<div class="post-metadata">

### Author: ![Grantst](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/g/5f9b8f/32.png) [@Grantst](https://discourse.devontechnologies.com/u/Grantst)
#### Post date: [January 14, 2022, 11:17pm UTC](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764/43 "2022-01-14T23:17:07Z")

</div>

@cgrunenberg or @BLUEFROG and others, what is the best current method of converting .md files within DT3 to docx in 2022? Is there any approach you would recommend? I don’t like docx but my work demands it. I have tried a few external apps like Markdown2, and Typora, but they seem to not be able to recognise images that are stored within DT3 and output them. Preferably the output would as closely match the markdown as possible and prevent have to do a lot of reformatting on the word document. Converting to rft then to word look nowhere near as good as the .md files themselves, it works but looks a little rough. Would a combination of script and pandoc be the way to go to?

---

<div class="post-metadata">

### Author: ![Bernardo\_V](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bernardo_v/32/7312_2.png) [@Bernardo\_V](https://discourse.devontechnologies.com/u/Bernardo_V)
#### Post date: [January 14, 2022, 11:22pm UTC](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764/44 "2022-01-14T23:22:20Z")

</div>

Create a docx template you like then use Pandoc to convert MD to DOCX using it.

---

<div class="post-metadata">

### Author: ![Grantst](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/g/5f9b8f/32.png) [@Grantst](https://discourse.devontechnologies.com/u/Grantst)
#### Post date: [January 15, 2022, 12:00am UTC](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764/45 "2022-01-15T00:00:34Z")

</div>

Thanks @Bernardo_V. I will have a. play with it. I gather it’s all done via terminal, which normally I’ve never had reason to look at. Are there any resources/tutorials to get newcomers acquainted that you are aware of? Or is it simpler than imagined?

---

<div class="post-metadata">

### Author: ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)
#### Post date: [January 15, 2022, 11:05am UTC](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764/46 "2022-01-15T11:05:43Z")

</div>

> [@Grantst](#):
>
> @cgrunenberg or @BLUEFROG and others, what is the best current method of converting .md files within DT3 to docx in 2022?

At least the easiest approach is via _File \> Export_ and importing the exported file.

---

<div class="post-metadata">

### Author: ![Grantst](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/g/5f9b8f/32.png) [@Grantst](https://discourse.devontechnologies.com/u/Grantst)
#### Post date: [January 15, 2022, 11:13am UTC](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764/47 "2022-01-15T11:13:06Z")

</div>

I use that command to export to the desktop and get this message:

> Word cannot open the file because the file format does not match the file extension.

Is that a known issue?

---

<div class="post-metadata">

### Author: ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)
#### Post date: [January 15, 2022, 11:16am UTC](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764/48 "2022-01-15T11:16:18Z")

</div>

Which export did you use and which version of DEVONthink?

---

<div class="post-metadata">

### Author: ![Grantst](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/g/5f9b8f/32.png) [@Grantst](https://discourse.devontechnologies.com/u/Grantst)
#### Post date: [January 15, 2022, 8:00pm UTC](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764/49 "2022-01-15T20:00:00Z")

</div>

Hi @cgrunenberg, using 3.8, _File \> Export \> As word 2007 Document (DOCX)_.

---

<div class="post-metadata">

### Author: ![Grantst](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/g/5f9b8f/32.png) [@Grantst](https://discourse.devontechnologies.com/u/Grantst)
#### Post date: [January 15, 2022, 8:55pm UTC](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764/50 "2022-01-15T20:55:48Z")

</div>

Hi @Bernardo_V, so downloaded Pandoc, checked to see if installed in terminal, put a markdown file on my desktop, open terminal, go to the desktop using _cd Desktop_, then run this command: _pandoc testfile.md -s -o testfile.docx_.

I get this message:

> pandoc: testfile.md: openBinaryFile: permission denied (Operation not permitted)

Same if use this: _pandoc testfile.md -f markdown -t docx -s -o testfile.docx_

Changing to rtf output also same message.

Any obvious mistakes?

---

<div class="post-metadata">

### Author: ![chrillek](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/chrillek/32/29340_2.png) [@chrillek](https://discourse.devontechnologies.com/u/chrillek)
#### Post date: [January 16, 2022, 12:37pm UTC](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764/52 "2022-01-16T12:37:16Z")

</div>

Other people have mentioned the same problem (as your favorite search engine will tell you). I guess that it has something to do with your shell setup, so typing `which pandoc` In the terminal might be a sensible first step to resolve the issue.

In any case, you should take this up with the pandoc people since it has nothing to do with DT

---

<div class="post-metadata">

### Author: ![P12](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/p/7c8e57/32.png) [@P12](https://discourse.devontechnologies.com/u/P12)
#### Post date: [January 16, 2022, 5:02pm UTC](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764/53 "2022-01-16T17:02:09Z")

</div>

I think the `-s` comes before the first filename, like this:

`pandoc -s testfile.md -o testfile.docx`

Not sure if that’ll make any difference but that’s how it is in my script!

Alternatively, might want to try [Marked 2](https://marked2app.com), which also exports to docx.

---

<div class="post-metadata">

### Author: ![Grantst](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/g/5f9b8f/32.png) [@Grantst](https://discourse.devontechnologies.com/u/Grantst)
#### Post date: [January 16, 2022, 11:00pm UTC](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764/54 "2022-01-16T23:00:47Z")

</div>

> [@chrillek](#):
>
> Other people have mentioned the same problem (as your favorite search engine will tell you). I guess that it has something to do with your shell setup, so typing `which pandoc` In the terminal might be a sensible first step to resolve the issue.

Thanks for the suggestions by yourself and others, will keep experimenting. I agree @chrillek it’s not a DT problem but was suggested by @Bernardo_V and the DT3 export is not working for me. I have a file that was done in markdown on DT3, with images also stored in DT3, but when these are opened in external editors the images are not recognised as the in DT3, they are linked in the form of ![namefile](x-devonthink-item://…), and that seems to be unrecognised so the pictures are missing. Perhaps @cgrunenberg will have a suggestion to get DT native export function working.

---

<div class="post-metadata">

### Author: ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)
#### Post date: [January 17, 2022, 5:48am UTC](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764/55 "2022-01-17T05:48:37Z")

</div>

An item link for an image isn’t going to work outside DEVONthink unless the external application had specifically coded to support it.

---

<div class="post-metadata">

### Author: ![Grantst](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/g/5f9b8f/32.png) [@Grantst](https://discourse.devontechnologies.com/u/Grantst)
#### Post date: [January 17, 2022, 6:55am UTC](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764/56 "2022-01-17T06:55:55Z")

</div>

Thanks @BLUEFROG do you know what’s wrong with the DT3 export option?

---

<div class="post-metadata">

### Author: ![chrillek](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/chrillek/32/29340_2.png) [@chrillek](https://discourse.devontechnologies.com/u/chrillek)
#### Post date: [January 17, 2022, 8:18am UTC](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764/57 "2022-01-17T08:18:02Z")

</div>

Although I can’t speak for the developers, I guess there’s nothing wrong with the export per se. Word did offer the possibility to refer to images by reference in the past, and I guess that this is still possible today. A reference is roughly the same as a link, so translating the latter to the former in export seems obvious.

You could try to convert your file first to a formatted note and than this one to a docx. Formatted notes embed images (and other links, afaik).

---

<div class="post-metadata">

### Author: ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)
#### Post date: [January 17, 2022, 8:58am UTC](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764/58 "2022-01-17T08:58:40Z")

</div>

> [@Grantst](#):
>
> Perhaps @cgrunenberg will have a suggestion to get DT native export function working.

Does changing the extension to .doc make a difference? Or is TextEdit or Pages able to open the document?

---

<div class="post-metadata">

### Author: ![Grantst](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/g/5f9b8f/32.png) [@Grantst](https://discourse.devontechnologies.com/u/Grantst)
#### Post date: [January 17, 2022, 9:01am UTC](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764/59 "2022-01-17T09:01:55Z")

</div>

Thanks for responding. I am not sure if the problem was clear. The exported DOCX from DT3 can’t be opened. Can save it to desktop. But it gives this error when try to open in Word:

> Word cannot open the file because the file format does not match the file extension.

So that’s in part why looking at 3rd party apps but as @BLUEFROG states they can’t display item links which they all are in my longish markdown document.

---

<div class="post-metadata">

### Author: ![Grantst](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/g/5f9b8f/32.png) [@Grantst](https://discourse.devontechnologies.com/u/Grantst)
#### Post date: [January 17, 2022, 9:17am UTC](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764/60 "2022-01-17T09:17:27Z")

</div>

It does open with doc extension but results aren’t good. It was unreadable as the font was black on dark background (am running Monterey 12.0.1 in auto light/dark appearance and it’s night here). When change to light mode in system settings its mostly white font on white background.  
It does open in text edit with docx extension, but it is a grey on dark background. Pages similarly can open but white on white background.  
With Mellel this message appears:

> The document “Cheat sheet.docx” could not be opened. Can’t open zip archive

Hope that helps

---

<div class="post-metadata">

### Author: ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)
#### Post date: [January 17, 2022, 9:52am UTC](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764/61 "2022-01-17T09:52:33Z")

</div>

> [@Grantst](#):
>
> When change to light mode in system settings its mostly white font on white background.

Do you use your own stylesheet or the internal one?

[Previous page](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764.md?page=2)

[Next page](https://discourse.devontechnologies.com/t/convert-markdown-to-pdf-docx-in-devonthink-using-pandoc/45764.md?page=4)
