Learn
Command-line convert to PDF
Command-line convert to PDF
Alpha status: XiKey Write is in Alpha. This page describes the
convertcommand ofxiwrite-cli, the command-line tool installed beside the app.
xiwrite-cli convert turns a document into another format without opening a window. Other programs, such as XiKey PDF, call it to turn Word, OpenDocument, RTF, HTML, Markdown and text files into PDF. The command line, the exit codes and the error line below are stable across minor versions.
Command
xiwrite-cli convert <in> <out.pdf> [--page-size a4|letter] [--markup] [--format wordml2003|flatopc]
<out>may also be docx, odt, rtf, html, md, tex, txt, json, png or xml. The format comes from the extension.--page-size a4|lettersets the paper (upper or lower case,--page-size=a4also works).--versionprintsxiwrite-cli X.Y.Z.- On success the tool prints
wrote <out>on stderr and exits 0. That line has not changed.
Exit codes
| Code | Name | Meaning |
|---|---|---|
| 0 | Done. | |
| 2 | usage |
Missing argument, unknown option, a bad or repeated option value, such as --page-size a5. |
| 3 | input |
The input is missing, a folder, unreadable or corrupt. |
| 4 | encrypted |
The input is password-protected. The command never asks for or accepts a password. |
| 5 | output |
The output cannot be written: the folder is missing, the path is a folder, or the file is read-only or not writable. An existing file is left as it was. |
| 6 | unsupported |
The input is not a document or text file XiKey Write reads (for example a workbook or a binary file), or the output extension is not a format it saves. |
| 7 | internal |
An unexpected failure. |
Error line
Every failure prints exactly one line on stderr and nothing on stdout:
xiwrite-cli: <code-name>: <detail>
<code-name> is one of usage, input, encrypted, output, unsupported, internal. The detail is plain English on one line (at most 400 characters). Read the exit code, not the detail, to decide what to do. The detail can name the file path you gave.
Page size
--page-size applies to the formats that carry no page setup of their own: plain text, Markdown and HTML. For those files it overrides the default paper. Without the flag they use the system region's paper (Letter in the US and other Letter regions, A4 elsewhere), as before. Set the reviewed source_REGION=en-US or another tag to make that default the same on every computer.
Word (docx, doc), OpenDocument and RTF files carry their own page setup and keep it, with or without --page-size. The flag never resizes them. To print a Word document on other paper, change its page setup in XiKey Write first.
What the command does not do
- It starts no window and needs no display.
- It opens no network connection. Pictures and style sheets that an HTML file points to by web address are not fetched. Only pictures beside the file on your computer are read.
- It runs no macros. Macro-enabled files are read as documents and their code is ignored.
- It never asks questions. It reads the input, writes the output and exits.
Other xiwrite-cli commands (info, text, render, run, mcp and the rest) are unchanged and still exit 1 on any failure. Only convert uses the codes above.
Arabic
Arabic text converts to PDF with the letters joined, in the right order, with the font embedded. The computer needs an Arabic font, the one bundled with the official release or an installed one.
Example
xiwrite-cli convert report.docx report.pdf
xiwrite-cli convert notes.txt notes.pdf --page-size a4
In a script, test the exit code: 0 means report.pdf is complete; any other value means the output was not written.