XPS to PDF Rest API.

The API for converting XPS documents to PDF files.

API Request

Parameter Description Value
Secret

Optional

String

Authentication secret (if omitted, token must be provided)

Secret
Token

Optional

String

Authentication token (if omitted, secret must be provided)

Token
Parameter Description Value
FileName

Optional

String

File name (without extension) of the converted file.

FileName
File

Required

File

File to be converted. Value can be URL or file content.

File
Parameter Description Value
Timeout

Optional

Integer

Conversion timeout in seconds.

Default: 300

Values: 10 .. 1200

Timeout
StoreFile

Optional

Bool

Store converted file on server.

Default: False

StoreFile
Parameter Description Value
PdfVersion

Optional

Collection

Set PDF version.

Default: 1.5

Values: 1.2, 1.3, 1.4, 1.5, 1.6, 1.7

PdfVersion
PdfResolution

Optional

Integer

Set PDF resolution.

Default: 300

Values: 10 .. 2400

PdfResolution
Parameter Description Value
DocumentTitle

Optional

String

Set the subject of the generated PDF file. If value is not set a source document title is used instead.

DocumentTitle
DocumentSubject

Optional

String

Set the subject of the generated PDF file. If value is not set a source document subject is used instead.

DocumentSubject
DocumentAuthor

Optional

String

Set the subject of the generated PDF file. If value is not set a source document author is used instead.

DocumentAuthor
DocumentKeywords

Optional

String

Set the subject of the generated PDF file. If value is not set a source document keywords are used instead.

DocumentKeywords

Snippets are autogenerated according to converter parameter choices above. Please select file in "File" or "Files" parameter before using code snippets.

Media Types

Authentication parameter (secret or token) always must be provided as a query parameter.

Request

  • application/json - JSON scheme also can be built in Code Snippets section. File data must be encoded with Base64 encoding, provided as URL or uploaded File ID. DOC to PDF scheme example:
    POST https://v2.convertapi.com/doc/to/pdf?Secret=XXX
    {
        "Parameters": [
            {
                "ConversionTime": 3,
                "Name": "File",
                "FileValue": {
                    "Name": "my_file.doc",
                    "Data": "--Base64 encoded file content--"
                }
            }
        ]
    }
    Merge PDF scheme example:
    POST https://v2.convertapi.com/pdf/to/merge?Secret=XXX
    {
        "Parameters": [
            {
                "Name": "StoreFile",
                "Value": "true"
            },
            {
                "Name": "PdfVersion",
                "Value": "1.7"
            },
            {
                "Name": "Files",
                "FileValues": [
                    {
                        "Name": "file.pdf",
                        "Data": "--Base64 encoded file content--"
                    },
                    {
                        "Url": "http://example.com/myfile.docx"
                    },
                    {
                        "Id": "13232131"
                    }
                ]
            }
        ]
    }
  • multipart/form-data - Each request parameter must be in separate part. If there is an array type parameter, index must be appended to parameter name e.g. Files[0], Files[1], Files[2] etc. DOC to PDF example:
    POST /doc/to/pdf?secret=XXXX HTTP/1.1
    Host: v2.convertapi.com
    Cache-Control: no-cache
    Content-Type: multipart/form-data; boundary=----7MA4YWxkTrZu0gW
    
    ------7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="StoreFile"
    
    true
    ------7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="File"; filename="my_file.doc"
    Content-Type: 
    
    --FILE DATA--
    ------7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="DocumentTitle"
    
    Test title
    ------7MA4YWxkTrZu0gW--
  • query parameters - Using query parameters it is possible to convert file which is accessible by URL or uploaded File ID. DOCX to PDF URL example:
    https://v2.convertapi.com/docx/to/pdf?Secret=XXX&File=http://example.com/myfile.docx&StoreFile=true
    If there is an array type parameter, index must be appended to parameter name e.g. Files[0], Files[1], Files[2] etc.

Response

Response headers and body contains this information:

  • ConversionTime - time in seconds that took to convert file. In this ammount of seconds your balance will be decreased after conversion.
  • FileName - name of converted file.
  • FileSize - converted file size in bytes.
  • FileData - converted file content.
  • FileUrl - link to converted file if "StoreFile" parameter is set to "true".

Response examples by media type:
  • application/json - response scheme can be explored in Test Request response box. Single file result example:
    {
        "ConversionTime": 2,
        "Files": [
            {
                "FileName": "my_file.pdf",
                "FileSize": 523672,
                "FileData": "--Base64 encoded file content--"
            }
        ]
    }
  • application/xml - XML scheme is analogous to JSON. Single file result example:
    <Conversion xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <ConversionTime>2</ConversionTime>
        <Files>
            <File>
                <FileName>my_file.pdf</FileName>
                <FileSize>522579</FileSize>
                <FileData>--Base64 encoded file content--</FileData>
                <Url i:nil="true" />
            </File>
        </Files>
    </Conversion>
  • multipart/mixed - each part contains converted file data or URL to the file. Single file result example:
    --43cf1475-ab15-4c6b-b5ee-e2cbcedfe92f
    ConversionTime: 3
    Content-Type: application/octet-stream
    Content-Disposition: attachment; filename="my_file.pdf"; size=8475
    
    --FILE CONTENT--
                    
    --43cf1475-ab15-4c6b-b5ee-e2cbcedfe92f--
  • application/octet-stream - response body is result file content. File name can be found in content-disposition header field. Can be used with converters that produce only one file result.

Other features

  • Converted files that are stored on convertapi.com server can be accessible for further conversion operations. This method allows conversion chaining, without increased network load. Example: conversion PDF to JPG produces as many files as there are pages in PDF file. If these files are stored on the server and links to the files are passed to ZIP converter, result will be one ZIP file with JPG files of each PDF page.
  • If ?view=true is appended to a stored conversion result file download link, file will be viewed in browser rather than downloaded. Example:
    https://v2.convertapi.com/d/HQ5TRU5Z/my_file.pdf?view=true