Office-to-PDF Conversion

Information

PSPDFKit Server has been deprecated and replaced by Document Engine. To start using Document Engine, refer to the migration guide. With Document Engine, you’ll have access to robust new capabilities (read the blog for more information).

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

Try for Free Launch Demo

The conversion of Office documents to PDF is also available for PSPDFKit for Web Standalone. For more information, see the Office-to-PDF guide.

Licensing

To convert Office documents to PDF with PSPDFKit for Web Server-Backed, contact Sales to add Office support to your license.

Example

The following example illustrates conversion 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.

OCR and Office Conversion Engines

Starting with version 2023.1, PSPDFKit for Web Server-Backed uses optical character recognition (OCR) and Office conversion engines based on GdPicture.NET. These engines deliver quality and performance improvements over the previous OCR engine based on Tesseract and LibreOffice. For more information about this change, updating your license, and reverting to the old engines, see the 2023.1 migration guide.