Convert Word, Excel and PowerPoint files to PDF

Office files need an office suite to lay them out. Send one by URL or as an upload, get a PDF and its page count back, and learn where conversions go wrong before your users find out.

Sooner or later a product that handles documents receives a .docx. A contract template edited in Word, a price list exported from Excel, a sales deck someone wants attached to a proposal. Browsers cannot render these, so none of the HTML tools from the first two lessons help. Converting them yourself means installing LibreOffice on a server, keeping its fonts current and stopping a hung conversion from eating a worker.

Office to PDF (officetopdf) runs that conversion for you, with LibreOffice. It accepts Word (doc, docx), Excel (xls, xlsx), PowerPoint (ppt, pptx), OpenDocument (odt, ods, odp), RTF, plain text and CSV, up to 10 MB per document. Each call converts one document and costs 30 credits.

Two ways to send the document

The one input parameter is document, and it takes either form:

  • A public URL to the file, as a JSON body: {"document": "https://..."}. The definition also accepts url as an alias for the same parameter.
  • The file itself, as a multipart/form-data upload with the field name document.

Start with the URL form, because it is the one you can try from this page:

Try it liveOffice to PDF30 credits
POSThttps://api.apiverve.com/v1/officetopdf
curl -X POST "https://api.apiverve.com/v1/officetopdf" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"document":"https://raw.githubusercontent.com/apache/poi/trunk/test-data/document/SampleDoc.docx"}'
Sign in or create a free account to run this with your own key.

inputFormat is detected from the file's contents; pageCount tells you how many pages the PDF has.

That sample Word document converts to a two-page PDF. The response gives you more to work with than the HTML renderers did:

FieldWhat it is
pageCountPages in the resulting PDF
inputFormatThe format the document was converted as, detected from its contents
inputNameThe input file name, such as SampleDoc.docx
sizeSize of the PDF in bytes
pageRangesThe pages converted, or null for the whole document
landscapeWhether landscape orientation was applied
downloadURL, expires, pdfNameThe signed link (valid for 2 days), its expiry in milliseconds, and the file name

The same call with an Excel workbook (SampleSS.xlsx from the same test-data repository) returned inputFormat: "xlsx" and two pages, and a PowerPoint deck (SampleShow.pptx) returned inputFormat: "pptx" and two pages, one per slide.

Which input form to use

The URL form is convenient when the file already sits somewhere public, but "public" is the catch. The service fetches the URL from the internet without your credentials, so a link to a private bucket or an intranet share fails. Making a contract publicly readable so a converter can fetch it is the wrong trade.

There is a middle path when files live in your object storage: generate a short-lived signed URL (a few minutes is plenty) and send that. The file stays private, the link is useless shortly afterwards, and your server never has to hold the bytes.

The upload form is right when the bytes are already in your process, typically because a user just uploaded them to you. Two limits apply: 10 MB per document, and uploads on the Free plan are limited to 400 KB. A typical text-heavy DOCX fits under 400 KB; a deck with photos usually does not. If your own upload form accepts larger files than your plan forwards, you will see that as a 400 naming the size ceiling, so check sizes before calling and give the user a clear message instead.

Check yourself

Your app stores customer contracts in a private storage bucket. What is the best way to convert one with Office to PDF?

Answer the check above to continue.

Run every example on your own key. Free plan, no card.

Scaling up?

Volume pricing, custom SLAs, and dedicated support for high-traffic teams.

Contact sales