DOCX to PDF API
High-speed DOC/DOCX to PDF API with pixel-perfect accuracy. Enterprise security, advanced parameters, no MS Office required.
Sometimes the right place to convert a file is not an application - it is a terminal. CI pipelines, cron jobs, server maintenance scripts, one-off batch jobs: they all want a command, not a code project. This guide shows how to convert files from the command line on any platform - a curl one-liner, a Bash batch loop, a native PowerShell script, and a dedicated CLI tool - plus an honest look at when offline tools like LibreOffice do the job.
All examples convert DOCX to PDF, but the same pattern works for any of the 500+ conversions: the endpoint is always https://v2.convertapi.com/convert/<source>/to/<destination>.
curl ships with Linux, macOS, and Windows 10+, so this exact command works everywhere. With download=attachment, the API streams the converted file straight back - no JSON parsing, no second request:
curl -X POST "https://v2.convertapi.com/convert/docx/to/pdf?download=attachment" \
-H "Authorization: Bearer api_token" \
-F "File=@report.docx" -o report.pdf
That is the whole integration. Swap docx and pdf in the URL for any other pair - xlsx/to/pdf, html/to/png, pdf/to/compress - and add converter parameters as extra -F fields.
Wrap the one-liner in a loop to convert everything in a directory:
for f in *.docx; do
curl -s -X POST "https://v2.convertapi.com/convert/docx/to/pdf?download=attachment" \
-H "Authorization: Bearer api_token" \
-F "File=@$f" -o "${f%.docx}.pdf"
echo "converted: $f"
done
Run conversions in parallel with xargs -P when the folder is large - the API does not rate-limit simultaneous requests on Business and Enterprise plans.
On Windows, curl.exe works in both cmd and PowerShell. But if your automation lives in PowerShell modules and scheduled tasks, the native pattern with Invoke-RestMethod gives you objects, error records, and no external dependencies:
$Token = "api_token"
$Uri = "https://v2.convertapi.com/convert/docx/to/pdf"
$Response = Invoke-RestMethod -Uri $Uri -Method Post `
-Headers @{ Authorization = "Bearer $Token" } `
-Form @{ File = Get-Item "C:\docs\report.docx"; StoreFile = "true" }
foreach ($File in $Response.Files) {
Invoke-WebRequest -Uri $File.Url -OutFile (Join-Path "C:\docs\out" $File.FileName)
Write-Host "converted: $($File.FileName)"
}
-Form handles the multipart upload natively (PowerShell 6+). If script execution is blocked on a fresh machine, allow it for the current session first: Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass.
For multi-file operations - merging PDFs, batch jobs with parameters - the open-source ConvertAPI CLI packs the whole API into one executable for Linux, Windows, and macOS. Download it from the releases page and run:
# single conversion
convertapi-cli api_token ./out report.docx
# merge several PDFs into one
convertapi-cli api_token ./out file1.pdf file2.pdf file3.pdf pdf merge
# password-protect with parameters
convertapi-cli api_token ./out report.pdf pdf protect UserPassword=1234
Exit codes distinguish validation errors from API errors, which makes it easy to wire into CI steps and shell scripts.
Honest answer: for casual, low-stakes conversions on your own machine, offline tools are fine.
soffice --headless --convert-to pdf report.docx) is free and offline. The trade-off is fidelity - complex layouts, embedded fonts, tracked changes, and charts often render differently than Word - plus you need LibreOffice installed on every machine and container that runs the job.An API earns its keep when output quality must match Microsoft Office rendering, when you need format breadth beyond documents (images, CAD, email, ebooks), when installing office suites into CI runners and containers is not welcome, or when volume calls for parallel processing. The one-liner above needs nothing but curl.
We ran the exact curl one-liner from this post on a two-page report document - the response streamed back a finished PDF:
Use the curl one-liner above - it needs no office suite, renders with full layout fidelity, and works the same in a container or CI runner.
Yes. Loop with Bash or PowerShell, parallelize with xargs -P, or pass multiple files to the CLI tool. Simultaneous requests are not rate-limited on Business and Enterprise plans.
Yes - curl.exe has shipped with Windows since Windows 10 build 1803, so the same one-liner works in cmd and PowerShell without installing anything.
Files are transferred over HTTPS, processed in memory, and deleted automatically after conversion. ConvertAPI holds SOC 2, ISO 27001, HIPAA, and GDPR compliance - see the security overview.
One curl command converts a file from any terminal; Bash and PowerShell loops scale it to folders; the CLI tool covers multi-file operations. Pick the converter you need - like DOCX to PDF - and the interactive demo will generate the exact call, parameters included, while you experiment.