Does UniOffice support DOCX to PDF conversion?
Yes, and without an external tool or a Word installation. document/convert
lays the document out and produces the PDF in process, so it runs anywhere Go
runs, including a container.
For the code, see How to convert MS Word (*.docx) file into PDF using UniOffice? or the conversion guides. This page is about what the converter does and does not handle, which is the part worth knowing before you commit to it.
What it renders
Paragraph and run formatting, styles, tables, images, headers and footers, page size and orientation, columns, bullets and numbering, hyperlinks, text boxes and charts all convert.
Where it falls short
Fields are mostly not evaluated. The converter recognizes PAGE,
NUMPAGES, FORMCHECKBOX and REF. Every other field code is left alone
without a warning. The one that bites people is TOC: a table of contents
written by UniOffice carries a field instruction and no computed entries, so
converting it straight to PDF produces a blank contents page. Opening and saving
the document in Word first, or generating the TOC through the OLE path, fills the
field in and then it renders.
Fonts substitute silently. Helvetica, Courier and Times New Roman map to the
built-in PDF base fonts. Anything else has to be registered from a TTF file with
convert.RegisterFont or RegisterFontsFromDirectory first; if it is not, the
text is drawn in Helvetica. Nothing errors, and because the metrics differ the
text is all present with the line breaks in the wrong places. This is the usual
cause of a conversion that looks almost right.
Registration is TTF only. RegisterFontsFromDirectory filters on the .ttf
suffix and skips everything else without comment, and it returns nil even when
nothing was registered.
Legacy formats are not supported. UniOffice reads .docx, .xlsx and
.pptx. Every reader opens the file as a ZIP archive, which is what an Open XML
package is, and returns parsing zip: ... when it is not one. A pre-2007
.doc, .xls or .ppt uses the older OLE compound binary format, so it fails
there rather than converting. Convert such files to the modern format first.
It is UniOffice’s rendering, not Word’s. Where the document relies on a feature the renderer does not implement, the output differs from what Word would produce. If matching Word exactly matters more than the deployment cost, the OLE path drives a real Word installation instead, at the price of a Windows host with Word licensed.
Licensing
Conversion needs two license keys, because the rendering half is UniPDF’s. It is the same key loaded into both libraries, and forgetting the second is the most common licensing problem reported against UniOffice. See Why does my license key fail when converting to PDF?
Spreadsheets and presentations convert too, through spreadsheet/convert and
presentation/convert, with the same dual-license requirement.