Viewing Package Creators
The Viewing Package Creator API provides a facility to fully convert a document for viewing prior to the creation of a Viewing Session. If a large document is converted for viewing at the time a Viewing Session is created, the user may experience a delay when viewing later pages in the document. By converting a document prior to viewing, the entire document is available for viewing immediately.
Note that these routes do not have route keys, as they cannot be re-routed.
POST /v2/viewingPackageCreators
Headers:
- Accusoft-Secret: mysecretkey
Body: a JSON object
The table below shows all the properties available for the POST Request:
Property | Type | Required | Description |
---|---|---|---|
input.source | {object} | Yes | Properties relevant to PAS will reside in this object. NOTE: This object will be removed before sending the rest of the body to the backend services. |
input.source.documentId | {string} | Yes | A customer supplied identifier which is used to uniquely identify the resulting viewing package. The documentId is required to have a non-zero length less than 256 characters and must consist of characters defined by RFC4648 - Base 64 Encoding with URL and Filename Safe Alphabet. |
input.source.type | {string} | Yes | Specify where PrizmApplicationServices can find the document. The valid values are "document", "url", or "upload". |
input.source.fileName | {string} | Yes (If source.type="document") | Filename that the Storage Provider API can use. |
input.source.url | {string} | Yes (If source.type="url") | URL to create a viewing session from. |
input.source.headers | {object} | Optional (Used if source.type="url") | Request headers to send from PrizmApplicationServices when retrieving the URL. |
input.source.acceptBadSslCertificate | {boolean=false} | Optional (Used if source.type="url") | If true, requires SSL certificates be valid. Note: to use your own certificate authority, you need to specify an agent that was created with that CA as an option. |
input.source.displayName | {string} | Yes (if source.type="upload") | The display name of the document that's being uploaded. E.g. "Sample-2015-09-30T19:17:24Z.doc" |
input.source.markupId | {string} | Optional | The ID to use when querying markup with the XML and JSON layer APIs. If one isn't passed, we create one from the other information we're given. |
input.source.downloadName | {string} | Optional | The name that will be used when downloading the original document. We will use the "displayName" or "fileName" if this option is not provided. |
input.source.fileExtension | {string} | Optional | A file extension that's used if the File Detection Service cannot determine what type of file was uploaded. We will get the extension from "displayName" or "fileName" if this option is not provided. |
input.viewingPackageLifetime | {integer} | Optional | Defines the minimum number of integer seconds for the created content to remain available. By default this is 24 hours. If set to 0, content will remain available perpetually. |
input.render | {object} | Optional | The object that describes rendering options. |
input.render.html5 | {object} | Optional | The object that describes rendering options for the HTML5 viewer. A whitelist of the following render properties is used: svgMaxImageSize and vectorTolerance . They are described in the PrizmDoc Server Viewing Session documentation. |
minSecondsAvailable | {integer} | Optional (if a value is not provided, the default value = 3600 seconds will be used) | Defines the minimum number of seconds for the conversion process to remain available to GET status. By default this is 3600 seconds because by default, the Viewing Sessions timeout after 20m. |
Examples
Create a Viewing Package using a local document
POST pas_base_url/v2/viewingPackageCreators
Content-Type: application/json
{
"input": {
"source": {
"type": "document",
"fileName": "sample.doc",
"documentId": "unT67Fxekm8lk1p0kPnyg8",
...
},
"viewingPackageLifetime": 2592000
}
}
Successful Response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"input": {
"source": {
"type": "document",
"fileName": "sample.doc",
"documentId": "unT67Fxekm8lk1p0kPnyg8",
...
},
"viewingPackageLifetime": 2592000
},
"expirationDateTime": "2015-12-09T06:22:18.624Z",
"processId": "khjyrfKLj2g6gv8fdqg710",
"state": "processing",
"percentComplete": 0
}
The response, along with other information, includes a new processId which is used to GET information about the converted content.
Errored Responses:
Duplicate POST Prior to Process Completion:
If a POST request is made with a body containing the exact same content as a request prior to the completion of the original process, an error similar to the one below will be returned.
HTTP/1.1 580 ConversionInProgress
Content-Type: application/json
{
"errorCode": "ConversionInProgress"
}
Duplicate POST After Process Completion:
If a POST request is made with a body containing the exact same content as a prior request after that request has completed, the following error similar to the one below will be returned.
HTTP/1.1 580 DocumentIdAlreadyInUse
Content-Type: application/json
{
"errorCode": "DocumentIdAlreadyInUse"
}
Note: An existing package must be deleted before re-submitting the same content for conversion.
Examples of Input Validation error responses
HTTP/1.1 480 MissingInput
Content-Type: application/json
{
"errorCode": "MissingInput",
"errorDetails": {
"in": "body",
"at": "input"
}
}
HTTP/1.1 480 InvalidInput
Content-Type: application/json
{
"errorCode": "InvalidInput",
"errorDetails": {
"in": "body",
"at": "input",
"expected": {
"type": "object"
}
}
}
If a POST request is made with either a missing or an invalid header Accusoft-Secret
, an error similar to the one below will be returned.
HTTP/1.1 403 InvalidSecret
Content-Type: application/json
{
"errorCode": "InvalidSecret"
}
Create a Viewing Package with extra options
PrizmDoc Server allows for render options that modify the output of the conversion process. The valid options are documented at the top of this page, but as an example, this is what a request would look like if you only wanted raster content:
Note: When creating a viewing package, watermarks cannot be used and will return an error.
POST pas_base_url/v2/viewingPackageCreators
Content-Type: application/json
{
"input": {
"source": {
"type": "document",
"fileName": "sample.doc",
"documentId": "unT67Fxekm8lk1p0kPnyg8",
...
},
"viewingPackageLifetime": 2592000
}
}
Successful Response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"input": {
"source": {
"type": "document",
"fileName": "sample.doc",
"documentId": "unT67Fxekm8lk1p0kPnyg8",
...
},
"viewingPackageLifetime": 2592000
},
"expirationDateTime": "2015-12-09T06:22:18.624Z",
"processId": "khjyrfKLj2g6gv8fdqg710",
"state": "processing",
"percentComplete": 0
}
Errored Responses:
Watermarks Input:
The input.watermarks
property cannot be used when creating a viewing package.
HTTP/1.1 480 ReservedInput
Content-Type: application/json
{
"errorCode": "ReservedInput",
"errorDetails": {
"in": "body",
"at": "input.watermarks"
}
}
PUT /v2/viewingPackageCreators/{processId}/SourceFile
Headers:
- Accusoft-Secret: mysecretkey
Body: a source document of Content-Type application/octet-stream
A request to this URL allows the user to upload a document to an existing viewing package creator which has not yet been provided a source document. When a viewing package creator is configured with input.source.type: 'upload', viewing package creation waits until a PUT request containing the source document is received. After the source document has been succesfully uploaded, viewing package creation will resume.
Examples
PUT pas_base_url/v2/viewingPackageCreators/khjyrfKLj2g6gv8fdqg710/SourceFile
Content-Type: application/octet-stream
<<file bytes>>
Successful Response:
HTTP/1.1 200 OK
Errored Responses:
When uploading a document for viewing package creation, the following errors may be encountered:
PUT When Not Allowed
If a PUT request is made to upload a file for a viewing package creator which does not have input.source.type: 'upload'
, then the following error will be returned.
HTTP/1.1 580 NotSupportedForViewingPackageSourceType
Content-Type: application/json
{
"errorCode": "NotSupportedForViewingPackageSourceType"
}
PUT When File Already Provided
If a PUT request is made to upload a file for a viewing package creator after a file has already been uploaded for that viewing package creator, then the following error will be returned.
HTTP/1.1 580 SourceFileAlreadyProvided
Content-Type: application/json
{
"errorCode": "SourceFileAlreadyProvided"
}
If a PUT request is made with either a missing or an invalid header Accusoft-Secret
, an error similar to the one below will be returned.
HTTP/1.1 403 InvalidSecret
Content-Type: application/json
{
"errorCode": "InvalidSecret"
}
GET /v2/viewingPackageCreators/{processId}
Headers:
- Accusoft-Secret: mysecretkey
Gets the status of an existing viewing package creator.
Requests to this URL can be sent repeatedly while the state="processing". To limit network congestion, an exponential back-off algorithm is recommended. This means that the time interval between each request is increased, which results in a good trade-off between quickly discovering short conversions that have completed and preventing a large number of requests for long conversions.
Upon successful package creation, the response will have the state="complete" with percentComplete=100. The errorCode will be null. Additionally it will include an output property which will contain the created package expiration time. If there is an error during processing, the state="error" with percentComplete=100. The exception to this is, some but not all page failures. In this case the state is set to "complete".
Examples
GET pas_base_url/v2/viewingPackageCreators/khjyrfKLj2g6gv8fdqg710
Viewing package creation completed successfully
A response for a package that was successfully generated would look like this:
HTTP/1.1 200 OK
Content-Type: application/json
{
"input": {
"source": {
"type": "document",
"fileName": "sample.doc",
"documentId": "unT67Fxekm8lk1p0kPnyg8",
. . .
},
"viewingPackageLifetime": 2592000
},
"output": {
"packageExpirationDateTime": "2016-1-09T06:22:18.624Z"
},
"expirationDateTime": "2015-12-09T06:22:18.624Z",
"processId": "khjyrfKLj2g6gv8fdqg710",
"state": "complete",
"percentComplete": 100
}
The viewing package creation process may encounter three types of errors, which it will report on as follows:
Source document not found
This error describes the conversion result for a nonexistent document. Note that upon completion in this error case, the state is set to "error" because no content could be provided for the document. Additionally, an errorCode property will be provided indicating this is the cause of the error. No output property will be provided when the process completes in an error state.
HTTP/1.1 200 OK
Content-Type: application/json
{
"input": {
"source": {
"type": "document",
"fileName": "sample.doc",
"documentId": "unT67Fxekm8lk1p0kPnyg8",
. . .
},
"viewingPackageLifetime": 2592000
},
"expirationDateTime": "2015-12-09T06:22:18.624Z",
"processId": "khjyrfKLj2g6gv8fdqg710",
"state": "error",
"percentComplete": 100,
"errorCode": "DocumentNotFound"
}
Incorrect password for source document
This error describes the conversion result for a password-protected document, which is not supported in this release. A password property may be provided in the request, but it will not be used. Upon completion in this error case, the state is set to "error" because no content could be provided for the document. An errorCode property will be provided indicating an "InternalError". No output property will be provided when the process completes in an error state.
HTTP/1.1 200 OK
Content-Type: application/json
{
"input": {
"source": {
"type": "document",
"fileName": "sample.pdf",
"documentId": "unT67Fxekm8lk1p0kPnyg8",
. . .
},
"password": "opensesame",
"viewingPackageLifetime": 2592000
},
"expirationDateTime": "2015-12-09T06:22:18.624Z",
"processId": "khjyrfKLj2g6gv8fdqg710",
"state": "error",
"percentComplete": 100,
"errorCode": "InternalError"
}
Individual page conversion failures
These errors will not mark the entire package as errored, but rather report in the output
object in a pageFailures
array.
HTTP/1.1 200 OK
Content-Type: application/json
{
"input": {
"source": {
"type": "document",
"fileName": "sample.doc",
"documentId": "unT67Fxekm8lk1p0kPnyg8",
. . .
},
"viewingPackageLifetime": 2592000
},
"output": {
"packageExpirationDateTime": "2016-1-09T06:22:18.624Z",
"pageFailures": [
{
"errorCode": "CouldNotRetrievePngContent",
"pageNumber": "4"
},
{
"errorCode": "CouldNotRetrieveSvgaContent",
"pageNumber": "5"
},
{
"errorCode": "CouldNotRetrieveTextContent",
"pageNumber": "8"
}
]
},
"expirationDateTime": "2015-12-09T06:22:18.624Z",
"processId": "khjyrfKLj2g6gv8fdqg710",
"state": "complete",
"percentComplete": 100
}
Attachment failures
These errors describe the failure of the conversion to provide an artifact for an attachment in the case where a document supports attachments, such as .EML or .MSG.
If the conversion process finds attachments associated with the document, but the process is unable to provide content for one or more pages, then the state is set to "complete" and an array of pageFailures
is returned as a property in the body.
Note: These errors differ from the document page failures by including the addition of an attachment
property. This property indicates the name of the attachment (as returned by the PCCIS GET Attachments API). In the eventuality the PPS supports the extraction of nested attachments, the attachments are referenced through an array of paths. Note that the original document is not included in the array of paths. If the original document is "message.eml", with an attachment of "fwd.eml", which has its own attachment of "financial.xls", the array would be ["fwd.eml"] or ["fwd.eml", "financial.xls"].
HTTP/1.1 200 OK
Content-Type: application/json
{
"input": {
"source": {
"type": "document",
"fileName": "sample.doc",
"documentId": "unT67Fxekm8lk1p0kPnyg8",
. . .
},
"viewingPackageLifetime": 2592000
},
"output": {
"packageExpirationDateTime": "2016-1-09T06:22:18.624Z",
"pageFailures": [
{
"errorCode": "CouldNotRetrieveJpegContent",
"pageNumber": "2",
"attachment": ["fwd.eml", "financial.xls"]
},
{
"errorCode": "CouldNotRetrieveSvgaContent",
"pageNumber": "3",
"attachment": "fwd.eml"
},
{
"errorCode": "CouldNotRetrieveTextContent",
"pageNumber": "4",
"attachment": "fwd.eml"
}
]
},
"expirationDateTime": "2015-12-09T06:22:18.624Z",
"processId": "khjyrfKLj2g6gv8fdqg710",
"state": "complete",
"percentComplete": 100
}
Error Responses
If a GET request is made with either a missing or an invalid header Accusoft-Secret
, an error similar to the one below will be returned.
HTTP/1.1 403 InvalidSecret
Content-Type: application/json
{
"errorCode": "InvalidSecret"
}