|
| 1 | +# ConvertAPI CLI Client |
| 2 | + |
| 3 | +## Convert your files with our command line file conversion utility |
| 4 | + |
| 5 | +The ConvertAPI helps converting various file formats. |
| 6 | +Creating PDF and Images from various sources like Word, Excel, Powerpoint, images, web pages or raw HTML codes. |
| 7 | +Merge, Encrypt, Split, Repair and Decrypt PDF files. |
| 8 | +And many others files manipulations. |
| 9 | +In just few minutes you can integrate it into your application or shell script and use it easily. |
| 10 | + |
| 11 | +The ConvertAPI CLI makes it easier to use the Convert API from your shell without having to build your own HTTP calls. |
| 12 | +You can get your free secret at https://www.convertapi.com/a |
| 13 | + |
| 14 | +## Installation |
| 15 | + |
| 16 | +Download compressed CLI executable |
| 17 | + |
| 18 | +* Linux: [convertapi_lin.zip](http://github) |
| 19 | +* Linux ARM64: [convertapi_lin_arm.zip](http://github) |
| 20 | +* Darwin (MacOS): [convertapi_mac.zip](http://github) |
| 21 | +* Windows: [convertapi_win.zip](http://github) |
| 22 | + |
| 23 | +(this utility also can be built from source code for many other CPU and OS) |
| 24 | + |
| 25 | +Unzip executable |
| 26 | + |
| 27 | +```shell |
| 28 | +unzip convertapi_*.zip |
| 29 | +``` |
| 30 | + |
| 31 | +And you are done. |
| 32 | +Optionally you can move executable file to more appropriate place and make utility accessible for all local users. On Linux would be: |
| 33 | + |
| 34 | +```shell |
| 35 | +sudo mv convertapi /usr/local/bin |
| 36 | +``` |
| 37 | + |
| 38 | +## Usage |
| 39 | + |
| 40 | +### Before you start |
| 41 | + |
| 42 | +In order to use this CLI utility you must create your free trial account on https://www.convertapi.com site. |
| 43 | +After sign up process you will get your secret at https://www.convertapi.com/a . |
| 44 | +Secret will be used in every CLI utility run. |
| 45 | + |
| 46 | +### Most basic file conversion |
| 47 | + |
| 48 | +Before we go in to details, short usage example how to convert DOCX file to PDF. |
| 49 | + |
| 50 | +```shell |
| 51 | +convertapi --iformat=docx --oformat=pdf --params="file:@/path/to/test.docx" --out="@/path/to/resultdir" --secret=<YOUR_SECRET_HERE> |
| 52 | +``` |
| 53 | + |
| 54 | +### Arguments documentation |
| 55 | + |
| 56 | +#### --iformat |
| 57 | +Input file format (file name extension). |
| 58 | +All supported input formats can be found [here](https://www.convertapi.com). |
| 59 | +_Example:_ |
| 60 | + |
| 61 | +```shell |
| 62 | +--iformat=docx |
| 63 | +``` |
| 64 | + |
| 65 | +#### --oformat |
| 66 | +Output file format (file name extension). |
| 67 | +All supported output formats can be found [here](https://www.convertapi.com). |
| 68 | +_Example:_ |
| 69 | + |
| 70 | +```shell |
| 71 | +--oformat=pdf |
| 72 | +``` |
| 73 | + |
| 74 | +#### --params |
| 75 | +Conversion parameter list. |
| 76 | +All supported conversion parameters can be found [here](https://www.convertapi.com). |
| 77 | +Parameter name and value is separated by `:` colon. |
| 78 | +Parameters are separated by `,` comma. |
| 79 | +_Example:_ |
| 80 | + |
| 81 | +```shell |
| 82 | +--params="param1:value1, param2:value2, param3:value3" |
| 83 | +``` |
| 84 | + |
| 85 | +##### File parameter |
| 86 | + |
| 87 | +Special case is file parameter. |
| 88 | +Value can have prefix and can be provided as an array with `;` semicolon separator. |
| 89 | +Prefix can be one of those: |
| 90 | + |
| 91 | +###### no prefix |
| 92 | + |
| 93 | +No prefix means that value is http or https scheme URL to file. |
| 94 | +_Example:_ |
| 95 | + |
| 96 | +```shell |
| 97 | +--params="file:https://cdn.convertapi.com/cara/testfiles/presentation.pptx" |
| 98 | +``` |
| 99 | + |
| 100 | +###### @ |
| 101 | + |
| 102 | +Parameter values starting from `@` are treated as paths to local files or directories. |
| 103 | +_Example:_ |
| 104 | + |
| 105 | +```shell |
| 106 | +--params="file:@/path/to/myfile.doc" |
| 107 | +``` |
| 108 | + |
| 109 | +###### < |
| 110 | + |
| 111 | +Parameters with `<` values are substituted with data taken from `STDIN`. |
| 112 | +As raw value can only be URL so in this case data received from `STDIN` should be URL or URL array separated by `\n` |
| 113 | +_Example:_ |
| 114 | + |
| 115 | +```shell |
| 116 | +--params="file:<" |
| 117 | +``` |
| 118 | + |
| 119 | +###### @< |
| 120 | + |
| 121 | +Parameters with `@<` values are substituted with data taken from `STDIN`. |
| 122 | +Data received from `STDIN` should be local path to file or directory. |
| 123 | +Also can be an array of paths separated by `\n`. |
| 124 | +_Example:_ |
| 125 | + |
| 126 | +```shell |
| 127 | +--params="file:@<" |
| 128 | +``` |
| 129 | + |
| 130 | +###### << |
| 131 | + |
| 132 | +Parameters with `<<` values are substituted with data taken from `STDIN`. |
| 133 | +Data received from `STDIN` should be file content. |
| 134 | +_Example:_ |
| 135 | + |
| 136 | +```shell |
| 137 | +--params="file:<<" |
| 138 | +``` |
| 139 | + |
| 140 | +##### Array parameter |
| 141 | + |
| 142 | +If parameter name is suffixed with `[]` parameter gets treated as an array parameter. |
| 143 | +Mainly array parameters are used when one conversion needs to accept multiple files (e.g. pdf merge or zip compression). |
| 144 | + |
| 145 | +```shell |
| 146 | +--params="files[]:@/path/to/dir" |
| 147 | +``` |
| 148 | + |
| 149 | +#### --out |
| 150 | + |
| 151 | +Argument defines how conversion result should be outputted. |
| 152 | +Values can be one of those: |
| 153 | + |
| 154 | +##### url |
| 155 | + |
| 156 | +This is default output method. It prints to `STDOUT` URL or array of URLs that point to converted files. |
| 157 | +This method should be used for conversion chaining. |
| 158 | + |
| 159 | +##### @ |
| 160 | + |
| 161 | +Value prefixed with `@` is treated as local file or directory path where converted file will be stored. |
| 162 | +_Example:_ |
| 163 | + |
| 164 | +```shell |
| 165 | +--out="@/path/to/result.pdf" |
| 166 | +``` |
| 167 | +or |
| 168 | +```shell |
| 169 | +--out="@/path/to/resultdir" |
| 170 | +``` |
| 171 | + |
| 172 | +##### stdout |
| 173 | + |
| 174 | +Conversion result will be outputted to `STDOUT`. |
| 175 | +If result consists of multiple files, second and other files will be outputted to file descriptors starting from 3. |
| 176 | + |
| 177 | +```shell |
| 178 | +--out="stdout" |
| 179 | +``` |
| 180 | + |
| 181 | +#### --secret |
| 182 | + |
| 183 | +ConvertAPI user secret. |
| 184 | +Get your secret at https://www.convertapi.com/a |
| 185 | + |
| 186 | +#### --version |
| 187 | + |
| 188 | +Outputs CLI utility version information and exits. |
| 189 | + |
| 190 | +#### --help |
| 191 | + |
| 192 | +Displays short usage information. |
| 193 | + |
| 194 | + |
| 195 | +### Examples |
| 196 | + |
| 197 | +Convert local DOCX file to PDF A3 page size saving result to `/path/to/resultdir` |
| 198 | +```shell |
| 199 | +convertapi --iformat=docx --oformat=pdf --params="file:@/path/to/test.docx, pagesize:a3" --out="@/path/to/resultdir" --secret=<YOUR_SECRET_HERE> |
| 200 | +``` |
| 201 | + |
| 202 | +Merge all PDF files that are in `/path/to/dir` directory and save it locally |
| 203 | +```shell |
| 204 | +convertapi --iformat=pdf --oformat=merge --params="files[]:@/path/to/dir" --out="@/path/to/resultdir" --secret=<YOUR_SECRET_HERE> |
| 205 | +``` |
| 206 | + |
| 207 | +Convert remote PPTX file to PDF saving result to `/path/to/result.pdf` |
| 208 | +```shell |
| 209 | +convertapi --iformat=pptx --oformat=pdf --params="file:https://example.com/myfile.pptx" --out="@/path/to/result.pdf" --secret=<YOUR_SECRET_HERE> |
| 210 | +``` |
| 211 | + |
| 212 | +Convert from DOCX to JPG and ZIP result JPG files |
| 213 | +```shell |
| 214 | +convertapi --iformat=docx --oformat=jpg --params="file:@/path/to/test.docx" --secret=<YOUR_SECRET_HERE> \ |
| 215 | + | convertapi --iformat=jpg --oformat=zip --params="files[]:<" --out="@/path/to/result.zip" --secret=<YOUR_SECRET_HERE> |
| 216 | +``` |
| 217 | + |
| 218 | +Convert DOCX to PDF and save result in remote server over SSH |
| 219 | +```shell |
| 220 | +convertapi --iformat=docx --oformat=pdf --params="file:@/path/to/test.docx" --out=stdout --secret=<YOUR_SECRET_HERE> \ |
| 221 | + | ssh user@myserver "cat >/tmp/my.pdf" |
| 222 | +``` |
| 223 | + |
| 224 | +Get PDF file from remote server, convert it to JPG and save result locally |
| 225 | +```shell |
| 226 | +ssh user@server "cat /tmp/my.pdf" \ |
| 227 | + | convertapi --iformat=pdf --oformat=jpg --params="file:<<" --out=@/path/to/resultdir --secret=<YOUR_SECRET_HERE> |
| 228 | +``` |
| 229 | + |
| 230 | +Do PDF->JPG and DOCX->JPG conversions in parallel and ZIP result JPG files |
| 231 | +```shell |
| 232 | +( \ |
| 233 | + convertapi --iformat=pdf --oformat=jpg --params="file:/path/to/dir" --secret=<YOUR_SECRET_HERE> \ |
| 234 | + & convertapi --iformat=docx --oformat=jpg --params="file:@/path/to/dir" --secret=<YOUR_SECRET_HERE> \ |
| 235 | +) | convertapi --iformat=jpg --oformat=zip --params="files[]:<" --out=@/path/to/resultdir --secret=<YOUR_SECRET_HERE> |
| 236 | +``` |
| 237 | + |
| 238 | +Merge PDFs files from various locations: remote SSH server, local file, local directory, remote HTTP server. |
| 239 | +Save result file to remote SSH server. All this done without writing to disk. |
| 240 | +```shell |
| 241 | +ssh user@server1 "cat /tmp/my.pdf" \ |
| 242 | + | convertapi --iformat=pdf --oformat=merge --params="files[]:<<;@/path/to/test.pdf;@/path/to/dir;https://example.com/my.pdf" --out=stdout --secret=<YOUR_SECRET_HERE> \ |
| 243 | + | ssh user@myserver2 "cat >/tmp/my.pdf" |
| 244 | +``` |
| 245 | + |
| 246 | +### Issues & Comments |
| 247 | +Please leave all comments, bugs, requests, and issues on the Issues page. We'll respond to your request ASAP! |
| 248 | + |
| 249 | +### License |
| 250 | +The ConvertAPI CLI is licensed under the [MIT](http://www.opensource.org/licenses/mit-license.php "Read more about the MIT license form") license. |
| 251 | +Refer to the [LICENSE](https://github.com/ConvertAPI/convertapi-cli/blob/master/LICENSE) file for more information. |
0 commit comments