Open MS Office Documents in a Web App

PSPDFKit for Web Server-Backed is capable of opening Office documents. The following table lists the supported Office file types.

File Extension MIME Type
DOC application/msword
DOCX application/vnd.openxmlformats-officedocument.wordprocessingml.document
XLS application/vnd.ms-excel
XLSX application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
PPT, PPS application/vnd.ms-powerpoint
PPTX application/vnd.openxmlformats-officedocument.presentationml.presentation
PPSX application/vnd.openxmlformats-officedocument.presentationml.slideshow

As with PDF documents, Office documents can be annotated and then printed or exported to PDF for sharing.

The Office document must be first imported using the Server API. To create a new document from an Office file, POST its contents to /api/documents:

Request

curl -X POST http://localhost:5000/api/documents \
  -H "Authorization: Token token=<secret token>" \
  -F file=@document.doc \
  -o result.pdf
POST /api/documents HTTP/1.1
Content-Type: multipart/form-data; boundary=customboundary

--customboundary
Content-Disposition: form-data; name="file"; filename="document.doc"

<doc data>
--customboundary--

Response

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

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

Once uploaded, you can open the Office document like you would any other document from PSPDFKit Server. Refer to the Office to PDF conversion guide for a more detailed description of the Office conversion APIs.