|
| 1 | +--- |
| 2 | +id: command-line-interface |
| 3 | +url: conversion/python-net/getting-started/command-line-interface |
| 4 | +title: Command Line Interface |
| 5 | +linkTitle: Command Line Interface |
| 6 | +second_title: Convert documents from the terminal with the groupdocs-conversion CLI |
| 7 | +weight: 6 |
| 8 | +keywords: command line, CLI, terminal, groupdocs-conversion, convert documents, shell, pipeline, CI, batch conversion, document info, supported formats, GroupDocs.Conversion, python |
| 9 | +description: "Convert documents straight from the terminal with the groupdocs-conversion command-line tool — no Python script required. Inspect documents, list supported formats, and apply a license, all from the shell." |
| 10 | +productName: GroupDocs.Conversion for Python via .NET |
| 11 | +hideChildren: False |
| 12 | +toc: True |
| 13 | +--- |
| 14 | + |
| 15 | +Installing the `groupdocs-conversion-net` package also puts a `groupdocs-conversion` console script on your `PATH`. It is a thin wrapper over the Python API, built for the cases where spinning up a Python script is overkill — shell pipelines, Make rules, CI steps, and one-off conversions. |
| 16 | + |
| 17 | +## Prerequisites |
| 18 | + |
| 19 | +The CLI ships inside the package, so no extra installation is needed. Make sure `groupdocs-conversion-net` is installed (see the [Quick Start Guide]({{< ref "conversion/python-net/getting-started/quick-start-guide.md" >}})), then verify the console script is available: |
| 20 | + |
| 21 | +```bash |
| 22 | +groupdocs-conversion --version |
| 23 | +``` |
| 24 | + |
| 25 | +You should see the package version printed, for example `groupdocs-conversion 26.5.0`. |
| 26 | + |
| 27 | +{{< alert style="info" >}} |
| 28 | +If the `groupdocs-conversion` command is not found, the package's script directory may not be on your `PATH`. You can always invoke the CLI through the Python module form instead: `python -m groupdocs.conversion`. The two are equivalent. |
| 29 | +{{< /alert >}} |
| 30 | + |
| 31 | +## Commands |
| 32 | + |
| 33 | +The CLI exposes four subcommands. Run `groupdocs-conversion --help` for the full flag listing, or `groupdocs-conversion <command> --help` for a specific subcommand. |
| 34 | + |
| 35 | +### convert |
| 36 | + |
| 37 | +Convert a document to another format. The target format is inferred from the output file extension; pass `--format` to override it. |
| 38 | + |
| 39 | +```bash |
| 40 | +# Extension picks the target format |
| 41 | +groupdocs-conversion convert business-plan.docx business-plan.pdf |
| 42 | + |
| 43 | +# Override the format when the output name doesn't carry a usable extension |
| 44 | +groupdocs-conversion convert business-plan.docx output.bin --format pdf |
| 45 | + |
| 46 | +# Convert a single page (1-indexed) — useful for raster targets |
| 47 | +groupdocs-conversion convert annual-review.pdf page1.png --page 1 --count 1 |
| 48 | + |
| 49 | +# Open a password-protected source |
| 50 | +groupdocs-conversion convert protected.docx protected.pdf --password "secret" |
| 51 | +``` |
| 52 | + |
| 53 | +| Option | Description | |
| 54 | +| :- | :- | |
| 55 | +| `--format` | Target format token (overrides the output extension). | |
| 56 | +| `--password` | Password for a protected source document. | |
| 57 | +| `--page` | First page to convert, 1-indexed. | |
| 58 | +| `--count` | Number of pages to convert. | |
| 59 | + |
| 60 | +On success the command prints the output path and exits with code `0`. |
| 61 | + |
| 62 | +### info |
| 63 | + |
| 64 | +Print basic information about a document — format, size, page count, and creation date when available. |
| 65 | + |
| 66 | +```bash |
| 67 | +groupdocs-conversion info annual-review.pdf |
| 68 | +``` |
| 69 | + |
| 70 | +```text |
| 71 | +format: pdf |
| 72 | +size: 291788 |
| 73 | +pages_count: 10 |
| 74 | +``` |
| 75 | + |
| 76 | +Use `--password` for protected sources. |
| 77 | + |
| 78 | +### list-formats |
| 79 | + |
| 80 | +List every target format the engine can produce for a given input document, split into primary and secondary targets. |
| 81 | + |
| 82 | +```bash |
| 83 | +groupdocs-conversion list-formats business-plan.docx |
| 84 | +``` |
| 85 | + |
| 86 | +Use `--password` for protected sources. |
| 87 | + |
| 88 | +### list-all-formats |
| 89 | + |
| 90 | +Print the full source-to-target conversion matrix known to the engine — every input format and the targets it can be converted to. |
| 91 | + |
| 92 | +```bash |
| 93 | +groupdocs-conversion list-all-formats |
| 94 | +``` |
| 95 | + |
| 96 | +This command takes no input file. |
| 97 | + |
| 98 | +## Global options |
| 99 | + |
| 100 | +These options apply to every command: |
| 101 | + |
| 102 | +| Option | Description | |
| 103 | +| :- | :- | |
| 104 | +| `--license PATH` | Apply a license file before running the command. | |
| 105 | +| `--version` | Print the CLI version and exit. | |
| 106 | +| `--help` | Show usage help and exit. | |
| 107 | + |
| 108 | +Apply a license up front by placing `--license` before the subcommand: |
| 109 | + |
| 110 | +```bash |
| 111 | +groupdocs-conversion --license GroupDocs.Conversion.lic convert business-plan.docx business-plan.pdf |
| 112 | +``` |
| 113 | + |
| 114 | +{{< alert style="info" >}} |
| 115 | +The CLI also honours the `GROUPDOCS_LIC_PATH` environment variable — if it is set, the license is applied automatically and you can omit `--license`. See the [Licensing]({{< ref "conversion/python-net/getting-started/licensing-and-subscription.md" >}}) topic for details. |
| 116 | +{{< /alert >}} |
| 117 | + |
| 118 | +## Format tokens |
| 119 | + |
| 120 | +`convert` maps the output extension — or the `--format` value, lowercased — to the matching convert options and file type. The supported tokens are: |
| 121 | + |
| 122 | +| Category | Tokens | |
| 123 | +| :- | :- | |
| 124 | +| PDF | `pdf` | |
| 125 | +| Word processing | `doc`, `docx`, `rtf`, `odt`, `txt`, `md` | |
| 126 | +| Spreadsheet | `xls`, `xlsx`, `xlsm`, `ods`, `csv`, `tsv` | |
| 127 | +| Presentation | `ppt`, `pptx`, `pptm`, `odp` | |
| 128 | +| Web | `html`, `htm`, `mhtml` | |
| 129 | +| Image | `jpg`, `jpeg`, `png`, `bmp`, `gif`, `tiff`, `tif`, `webp`, `svg` | |
| 130 | +| eBook | `epub`, `mobi`, `azw3` | |
| 131 | + |
| 132 | +An unknown token causes the command to exit with code `2` and print the list of accepted tokens. |
| 133 | + |
| 134 | +## Exit codes |
| 135 | + |
| 136 | +| Code | Meaning | |
| 137 | +| :- | :- | |
| 138 | +| `0` | Success. | |
| 139 | +| `2` | User error — unknown format token or missing input file. | |
| 140 | +| `1` | Runtime error — the underlying .NET exception message is printed to standard error. | |
| 141 | + |
| 142 | +These codes make the CLI easy to branch on in shell scripts and CI pipelines. |
| 143 | + |
| 144 | +## When to use the Python API instead |
| 145 | + |
| 146 | +The CLI covers the common single-document conversion cases. For anything beyond that — per-page callbacks, in-memory streams, watermark, font, or cell-range options, and multi-document container hierarchies — use the Python API directly. It exposes a richer surface than the CLI flags. See the [Developer Guide]({{< ref "conversion/python-net/developer-guide" >}}) for the full feature set. |
| 147 | + |
| 148 | +## Next Steps |
| 149 | + |
| 150 | +- [Quick Start Guide]({{< ref "conversion/python-net/getting-started/quick-start-guide.md" >}}): Convert your first document with the Python API. |
| 151 | +- [Supported File Formats]({{< ref "conversion/python-net/getting-started/supported-document-formats.md" >}}): Review the full list of supported file types. |
| 152 | +- [Licensing]({{< ref "conversion/python-net/getting-started/licensing-and-subscription.md" >}}): Apply a license to remove evaluation limits. |
| 153 | +- [Technical Support]({{< ref "conversion/python-net/technical-support" >}}): Contact support if you encounter issues. |
0 commit comments