Content Conversion
The content conversion API allows you to convert files from a variety of input formats to several common output formats.
To convert a file:
- Upload a file you want to use as input using the WorkFile API.
- Start a conversion operation by using the POST URL below.
- Check the status of the conversion by (repeatedly) using the GET URL below.
- When complete, a separate output file will exist which you can download via the WorkFile API.
Available URLs
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
.
POST /v2/contentConverters
Creates a new contentConverter resource which represents the conversion process and begins converting one or multiple input files 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.
Request Headers
Name | Value | Details |
---|---|---|
Content-Type |
application/json |
required |
Accusoft-Affinity-Token |
Affinity token returned in post response body for work file specified by Example: “rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w=” |
Only required if PCC is running in multi-server mode. |
Request Body
At a high level, your request body should be JSON containing an input
object with details about the sources
and dest
for the conversion.
Here is a minimal example:
POST http://localhost:18681/v2/contentConverters Content-Type application/json { "input": { "sources": [ { "fileId": "ek5Zb123oYHSUEVx1bUrVQ" } ], "dest": { "format": "pdf" } } }
Additional options are available. Here is the full reference:
input.sources
The input.sources
object specifies an array of objects, one for each input file.
Currently multiple input files are only supported when the destination format is
tiff
, but a future version of the product may allow you to submit multiple input source files for other destination formats.
Name | Description | Details |
---|---|---|
input.sources[n].fileId |
The id of the WorkFile to use as input. |
string, required Example: |
input.sources[n].pages |
Page numbers and/or page ranges separated by commas. Currently |
string, optional Example: |
input.src (deprecated)
The input.src
object specifies the file to use as input. This property has been deprecated, please use input.sources instead.
Name | Description | Details |
---|---|---|
input.src.fileId |
The id of the WorkFile to use as input. |
string, required Example: |
input.dest
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 |
input.dest.jpegOptions
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: |
For CAD input, you must specify either
maxWidth
ormaxHeight
.
input.dest.pdfOptions
Name | Description | Details |
---|---|---|
input.dest.pdfOptions.forceOneFilePerPage |
If Default is |
boolean, optional |
When converting PDF documents to a single PDF with multiple pages or a set of single-page PDF files, the result PDF file(s) will lose bookmarks and intra-document links due to restructuring of the PDF content.
input.dest.pngOptions
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: |
For CAD input, you must specify either
maxWidth
ormaxHeight
.
input.dest.tiffOptions
Name | Description | Details |
---|---|---|
input.dest.tiffOptions.forceOneFilePerPage |
If Default is |
boolean, optional |
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: |
For CAD input, you must specify either
maxWidth
ormaxHeight
.
minSecondsAvailable
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.
Response Body
A successful response will return JSON which contains:
- The
input
object submitted in the request, normalized to include default values. - Information about the status of the conversion.
Here is an example:
200 OK Content-Type: application/json { "input": { "sources": [ { "fileId": "ek5Zb123oYHSUEVx1bUrVQ", "pages": "" } ], "dest": { "format": "pdf", "pdfOptions": { "forceOneFilePerPage": false } } }, "expirationDateTime": "2015-12-17T20:38:39.796Z", "processId": "ElkNzWtrUJp4rXI5YnLUgw", "state": "processing", "percentComplete": 0 }
Conversion Status Details
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: |
affinityToken |
Affinity token echoed from request header. This value will only be present if PCC is running in multi-server mode. |
string Example: “rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w=” |
HTTP Status Codes
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.
GET /v2/contentConverters/{processId}
Gets the status of a content conversion operation and its final output if available.
In general, the response JSON will contain:
- The
input
object submitted in the POST request, normalized to include default values. - Information about the status of the conversion.
- Information about the output of the conversion, if available.
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.
Parameters
Name | Description | Details |
---|---|---|
processId |
The processId for a particular contentConverter. This processId was returned in the response for the initial POST. |
string, required |
Request Headers
Name | Value | Details |
---|---|---|
Accusoft-Affinity-Token |
Affinity token returned in post response body for content converter specified by Example: “rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w=” |
Only used if PCC is running in multi-server mode. |
Response Body
While processing, the response will return JSON with only the processing details. For example:
200 OK Content-Type: application/json { "input": { "sources": [ { "fileId": "ek5Zb123oYHSUEVx1bUrVQ", "pages": "" } ], "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 or TIFF), then only a single output file will be created. For example:
200 OK Content-Type: application/json { "input": { "sources": [ { "fileId": "ek5Zb123oYHSUEVx1bUrVQ", "pages": "" } ], "dest": { "format": "pdf", "pdfOptions": { "forceOneFilePerPage": false } } }, "expirationDateTime": "2015-12-17T20:38:39.796Z", "processId": "ElkNzWtrUJp4rXI5YnLUgw", "state": "complete", "percentComplete": 100, "output": { "results": [ { "fileId": "KOrSwaqsguevJ97BdmUbXi", "sources": [{ "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": { "sources": [ { "fileId": "ek5Zb123oYHSUEVx1bUrVQ" } ], "dest": { "format": "jpeg" } }, "expirationDateTime": "2015-12-17T20:38:39.796Z", "processId": "ElkNzWtrUJp4rXI5YnLUgw", "state": "complete", "percentComplete": 100, "output": { "results": [ { "fileId": "N6uDE11Ed6+JQPy0POu+8A", "sources": [{ "fileId": "ek5Zb123oYHSUEVx1bUrVQ", "pages": "1" }] }, { "fileId": "+4b6QW90Fb9yjDak+ALFEg", "sources": [{ "fileId": "ek5Zb123oYHSUEVx1bUrVQ", "pages": "2" }] }, { "fileId": "Lx/4z8AyJKV5eMjWKsBm5w", "sources": [{ "fileId": "ek5Zb123oYHSUEVx1bUrVQ", "pages": "3" }] } ] } }
Conversion Status Details
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: |
affinityToken |
Affinity token echoed from request header. This value will only be present if PCC is running in multi-server mode. |
string Example: “rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w=” |
Conversion Output Details
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].sources |
An array of objects, one for each source file which contributed to this output file. | array |
output.results[n].sources[n].fileId |
The WorkFile id of the source input file. | string |
output.results[n].sources[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: |
output.results[n].src (deprecated) |
An array with a single object which corresponds to input.src. This will only appear in the output if you used the deprecated input.src property instead of the new input.sources in the original POST request. | array |
HTTP Status Codes
200 OK
- The contentConverter was created and the conversion process was started.404 Not Found
- No contentConverter exists with the givenprocessId
. 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.
Appendix
Supported Input File Formats
Refer to the supported file types listed at http://www.accusoft.com/products/prizm-content-connect/features/.
Supported Output File Formats
- TIFF
- PNG
- JPEG
- SVG