Custom Widget: Create DOCX or PDF files from HTML or Markdown

Hi everyone,

here’s a widget that generates DOCX or PDF files from HTML or Markdown. It’s as simple as that! It uses the awesome Googoose library and html2pdf libraries to do the heavy lifting.
Images are supported, too. You may insert them as external URLs or from your Grist attachments, in that case just provide “attachchment:n” (where ‘n’ is a valid attachment ID) as the image’s URL.

You can see the whole thing in action here.

The source code and some documentation is available here.

Hope this proves useful to someone. Cheers!

3 Likes

Hi Tom,

Shortly downloaded image through documentize leads to issue on W11
Performed from the link you gave


image

It opens yet nicely on libreoffice (don’t tested on another comp/os)

@Sylvain_Page Hm, that’s not supposed to happen. I haven’t tested it very thoroughly with Word as I have only sporadic access to the program. But I’ll look into it and see what I can come up with!

By the way, if you should happen to have some time on your hands, you might try to Google the problem yourself. You see, the docx files generated by this widget are actually html files, just with some special formatting inside and a .docx extension. Word is supposed to open such a file as if it were a “real” docx and then automatically convert it into one. I’m pretty certain the problem is related to that. Maybe Word dropped support for this feature at some point…

@Sylvain_Page You’re on macOS, right? After doing some reading, I have a suspicion this may be related to Word on Apple, but I’m not sure. I fixed a trifling little but in Googoose, you may want to try it again now, but my bet is this won’t do the trick. Would you have any way of trying it out on a Windows computer?

Or perhaps somebody else could help out here?

I’m on Linux myself and I don’t own Word, so that makes it a bit difficult.

I’m having the same issue on Microsoft Word on Windows 10 Enterprise

@wunter8 Thanks for testing! That’s very strange. I tested this with both LibreOffice and Onlyoffice, and both work just fine. Will keep looking into it.

No I am on W10 and occasionnaly W11 :slight_smile:
Same issue on both os…
I confirm LibreOffice works well but Industrial world run with Microsoft most of the time.