Office-to-PDF Conversion

ℹ️ Note: This requires you to license Office support.

To convert an Office file to PDF, you need to upload your Office document to PSPDFKit for Web Server-Backed.

Launch Demo

The following example illustrates this using a Word file. To create a new document from a Word file, POST its contents to /api/document:

Request

curl -X POST http://localhost:5000/api/documents \
  -H "Authorization: Token token=<secret token>" \
  -F file=@/path/to/word.docx
POST /api/documents HTTP/1.1
Content-Type: multipart/form-data; boundary=customboundary

--customboundary
Content-Disposition: form-data; name="file"; filename="word.docx"
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document

<DOCX data>
--customboundary--

Response

HTTP/1.1 200 OK
Content-Type: application/json

{
  "data": {
    "document_id": ...,
    "errors": [],
    "sourcePdfSha256": ...,
    "title": "..."
  }
}

PSPDFKit for Web Server-Backed will automatically convert the uploaded file to a PDF and store it for you. Afterward, you can download it as a PDF using the document ID that was previously returned:

Request

GET /api/documents/:document_id/pdf
Authorization: Token token="<secret token>"
$ curl "http://localhost:5000/api/documents/:document_id/pdf \
   -H "Authorization: Token token=<secret token>"

Response

HTTP/1.1 200 OK
Content-Type: application/pdf

<PDF data>

Once an Office file is uploaded and converted, you can also treat it as you would any other document, using all the features PSPDFKit for Web Server-Backed provides.