Working with the Prizm Platform Services > API Reference > PCC RESTful API > Content Conversion Service |
The content conversion API allows you to convert files from a variety of input formats to several common output formats.
To convert a file:
URL | Purpose |
---|---|
POST /v2/contentConverters | Create and start a content conversion |
GET /v2/contentConverters/{processId} | Get the status of a content conversion |
Note that these URLs begin with
/v2
, not/PCCIS/V1
.
Creates a new contentConverter resource which represents the conversion process and begins converting an input file which you have previously uploaded using the WorkFile API. A successful response will include a unique processId
which identifies this contentConverter. You will use this processId
in subsequent GET calls to get the status and final results of the conversion.
Name | Value | Details |
---|---|---|
Content-Type |
application/json |
required |
At a high level, your request body should be JSON containing an input
object with details about the src
and dest
for the conversion.
Here is a minimal example:
POST http://localhost:18681/v2/contentConverters Content-Type application/json { "input": { "src": { "fileId": "ek5Zb123oYHSUEVx1bUrVQ" }, "dest": { "format": "pdf" } } }
Additional options are available. Here is the full reference:
The input.src
object specifies the file to use as input.
Name | Description | Details |
---|---|---|
input.src.fileId |
The id of the WorkFile to use as input. |
string, required Example: |
The input.dest
object specifies the destination file format and any additional details which control how the content is converted.
Name | Description | Details |
---|---|---|
input.dest.format |
Specifies the output file format. Must be one of the following:
|
string, required |
input.dest.jpegOptions |
Additional options when input.dest.format is "jpeg" . |
object, optional |
input.dest.pdfOptions |
Additional options when input.dest.format is "pdf" . |
object, optional |
input.dest.pngOptions |
Additional options when input.dest.format is "png" . |
object, optional |
input.dest.tiffOptions |
Additional options when input.dest.format is "tiff" . |
object, optional |
Name | Description | Details |
---|---|---|
input.dest.jpegOptions.maxWidth |
The maximum pixel width of the output image, expressed as a CSS-style string, e.g. "800px" . When specified, the output image is guaranteed to never be wider than the specified value and its aspect ratio will be preserved. This is useful if you need all of your output images to fit within a single column. |
string, optional Example: |
input.dest.jpegOptions.maxHeight |
The maximum pixel height of the output image, expressed as a CSS-style string, e.g. "600px" . When specified, the output image is guaranteed to never be taller than the specified value and its aspect ratio will be preserved. This is useful if you need all of your output images to fit within a single row. |
string, optional Example: |
Name | Description | Details |
---|---|---|
input.dest.pdfOptions.forceOneFilePerPage |
If true, the conversion process will produce single-page PDF files, one file for each page of content (instead of a single PDF with multiple pages). Setting this option to Default is |
boolean, optional |
Name | Description | Details |
---|---|---|
input.dest.pngOptions.maxWidth |
The maximum pixel width of the output image, expressed as a CSS-style string, e.g. "800px" . When specified, the output image is guaranteed to never be wider than the specified value and its aspect ratio will be preserved. This is useful if you need all of your output images to fit within a single column. |
string, optional Example: |
input.dest.pngOptions.maxHeight |
The maximum pixel height of the output image, expressed as a CSS-style string, e.g. "600px" . When specified, the output image is guaranteed to never be taller than the specified value and its aspect ratio will be preserved. This is useful if you need all of your output images to fit within a single row. |
string, optional Example: |
Name | Description | Details |
---|---|---|
input.dest.tiffOptions.forceOneFilePerPage |
When the destination format is We currently only support single-page TIFF output. We expect this may change in a future release, in which case this property would then become optional and use a default value of |
boolean, required with a value of true |
input.dest.tiffOptions.maxWidth |
The maximum pixel width of the output image, expressed as a CSS-style string, e.g. "800px" . When specified, the output image is guaranteed to never be wider than the specified value and its aspect ratio will be preserved. This is useful if you need all of your output images to fit within a single column. |
string, optional Example: |
input.dest.tiffOptions.maxHeight |
The maximum pixel height of the output image, expressed as a CSS-style string, e.g. "600px" . When specified, the output image is guaranteed to never be taller than the specified value and its aspect ratio will be preserved. This is useful if you need all of your output images to fit within a single row. |
string, optional Example: |
Allows you to specify a minimum number of seconds in which you can continue to GET the status of this conversion operation after the initial POST has been submitted. The default value is 60
, ensuring that you have at least 60 seconds to get the result status of any conversion operation.
A successful response will return JSON which contains:
input
object submitted in the request, normalized to include default values.Here is an example:
200 OK Content-Type: application/json { "input": { "src": { "fileId": "ek5Zb123oYHSUEVx1bUrVQ" }, "dest": { "format": "pdf", "pdfOptions": { "forceOneFilePerPage": false } } }, "expirationDateTime": "2015-12-17T20:38:39.796Z", "processId": "ElkNzWtrUJp4rXI5YnLUgw", "state": "processing", "percentComplete": 0 }
Name | Description | Details |
---|---|---|
processId |
The id of the contentConverter resource which represents the file conversion operation. | string |
expirationDateTime |
The date and time (in ISO 8601 Extended Format) when the contentConverter resource will be deleted. |
string Example: |
state |
The current state of the conversion process, which will be one of the following:
For the initial POST, this value will almost always be |
string |
percentComplete |
An integer from 0 to 100 that indicates what percentage of the conversion is complete. |
integer Example: |
errorCode |
An error code string if a problem occurred during the conversion process. |
string Example: |
200 OK
- The contentConverter was created and the conversion process was started.405 Method Not Allowed
- POST was not used.480
- Something was wrong with the request input. Check the response body for details.Gets the status of a content conversion operation and its final output if available.
In general, the response JSON will contain:
input
object submitted in the POST request, normalized to include default values.Requests can be sent to this URL repeatedly while the state
is "processing"
.
When the state
is "complete"
, the output
section will list one or more WorkFile ids for each output file, and the files themselves can be downloaded using the WorkFile API.
Name | Description | Details |
---|---|---|
processId |
The processId for a particular contentConverter. This processId was returned in the response for the initial POST. |
string, required |
While processing, the response will return JSON with only the processing details. For example:
200 OK Content-Type: application/json { "input": { "src": { "fileId": "ek5Zb123oYHSUEVx1bUrVQ" }, "dest": { "format": "pdf", "pdfOptions": { "forceOneFilePerPage": false } } }, "expirationDateTime": "2015-12-17T20:38:39.796Z", "processId": "ElkNzWtrUJp4rXI5YnLUgw", "state": "processing", "percentComplete": 82 }
Once the processing has completed, the response will return JSON showing the WorkFile id of the output file or files.
If the output format supports multiple pages (e.g. PDF), then only a single output file will be created. For example:
200 OK Content-Type: application/json { "input": { "src": { "fileId": "ek5Zb123oYHSUEVx1bUrVQ" }, "dest": { "format": "pdf", "pdfOptions": { "forceOneFilePerPage": false } } }, "expirationDateTime": "2015-12-17T20:38:39.796Z", "processId": "ElkNzWtrUJp4rXI5YnLUgw", "state": "complete", "percentComplete": 100, "output": { "results": [ { "fileId": "KOrSwaqsguevJ97BdmUbXi" "src": [{ "fileId": "ek5Zb123oYHSUEVx1bUrVQ", "pages": "1-3" }] } ] } }
If the output format does not support multiple pages (e.g. JPEG), then multiple output files will be created. For example:
200 OK Content-Type: application/json { "input": { "src": { "fileId": "ek5Zb123oYHSUEVx1bUrVQ" }, "dest": { "format": "jpeg" } }, "expirationDateTime": "2015-12-17T20:38:39.796Z", "processId": "ElkNzWtrUJp4rXI5YnLUgw", "state": "complete", "percentComplete": 100, "output": { "results": [ { "fileId": "N6uDE11Ed6+JQPy0POu+8A", "src": [{ "fileId": "mUiXiqsQuevJKO9Swa32Bd", "pages": "1" }] }, { "fileId": "+4b6QW90Fb9yjDak+ALFEg", "src": [{ "fileId": "mUiXiqsQuevJKO9Swa32Bd", "pages": "2" }] }, { "fileId": "Lx/4z8AyJKV5eMjWKsBm5w", "src": [{ "fileId": "mUiXiqsQuevJKO9Swa32Bd", "pages": "3" }] } ] } }
Name | Description | Details |
---|---|---|
processId |
The id of the contentConverter resource which represents the file conversion operation. | string |
expirationDateTime |
The date and time (in ISO 8601 Extended Format) when the contentConverter resource will be deleted. |
string Example: |
state |
The current state of the conversion process, which will be one of the following:
|
string |
percentComplete |
An integer from 0 to 100 that indicates what percentage of the conversion is complete. |
integer Example: |
errorCode |
An error code string if a problem occurred during the conversion process. |
string Example: |
Name | Description | Details |
---|---|---|
output.results |
An array of objects, one for each output file created. | object |
output.results[n].fileId |
The WorkFile id for an output file. Use this id to download the output file using the WorkFile API. | string |
output.results[n].src |
An array of objects, one for each source file which contributed to this output file (currently this array will only contain a single item, but a future version of the product may allow you to submit multiple input source files). | array |
output.results[n].src[n].fileId |
The WorkFile id of the source input file (currently this will always be the same as input.src.fileId ). |
string |
output.results[n].src[n].pages |
The page or pages used from the source file. This will be a string value using one-based indexing. For example, if the output file represents page 2 of the source document, |
string Examples: |
200 OK
- The contentConverter was created and the conversion process was started.404 Not Found
- No contentConverter exists with the given processId
. It is possible the contentConverter has expired and is no longer available.405 Method Not Allowed
- GET was not used.480
- Something was wrong with the request input. Check the response body for details.For a complete list, refer to Supported Document Types.