PrizmDoc v13.0 - Updated
Use a Viewing Session
Developer Guide > PrizmDoc Server > How To Examples > Use a Viewing Session

This section provides instructions on How to Use a Viewing Session in PrizmDoc Server:

Step 1: Create a Viewing Session

The recommended method of creating a Viewing Session is through the POST /ViewingSession endpoint in Application Services.

The body of the request specifies details of how the Viewing Session’s content will be generated and how its source document will be transferred to PrizmDoc, but does not necessarily provide the source document itself.

Example Request
Copy Code

POST http://localhost:18681/PCCIS/V1/ViewingSession

Content-Type: application/json

{

   "render": {

       "html5": {

           "alwaysUseRaster": false

       }

   }

}

Example Response
Copy Code

200 OK

Content-Type: application/json

{

    "viewingSessionId":"-gchUEYvBE5OCgcWJajgoXcW7QD0I8zNDFlexD9hzbXkmrYlw8DrxJ-KiHAf2oTAL_HiHK1MsstBlNgZFCrcJQ"

}

Step 2: (Optional) Upload the Source Document

If a Viewing Session was created with a documentSource of "api", a second request is required to provide it with the source document. For other source types, the source document will have already been specified in the externalId property, and this step should be skipped.

Example Request
Copy Code

PUT http://localhost:18681/PCCIS/V1/ViewingSession/u-gchUEYvBE5OCgcWJajgoXcW7QD0I8zNDFlexD9hzbXkmrYlw8DrxJ-KiHAf2oTAL_HiHK1MsstBlNgZFCrcJQ/SourceFile

Content-Type: application/octet-stream

{binary data}

Example Response
Copy Code

200 OK

Step 3: (Optional) Start the Session

By default, content generation for a Viewing Session does not begin until content is first requested from it. However, it is possible to manually kick off conversion beforehand in order to improve the response time of subsequent content requests.

Example Request
Copy Code

POST http://localhost:18681/PCCIS/V1/ViewingSession/u-gchUEYvBE5OCgcWJajgoXcW7QD0I8zNDFlexD9hzbXkmrYlw8DrxJ-KiHAf2oTAL_HiHK1MsstBlNgZFCrcJQ/Notification/SessionStarted

Content-Type: application/json

{

   "Viewer": "HTML5"

}

Example Response
Copy Code

200 OK

Step 4: Request Content

Once a Viewing Session has been created and provided with its source document, it becomes possible to make requests for content from it, as described in the HTML5 Viewing API reference.

Example Request
Copy Code

GET http://localhost:18681/PCCIS/V1/Page/q/0?DocumentID=u-gchUEYvBE5OCgcWJajgoXcW7QD0I8zNDFlexD9hzbXkmrYlw8DrxJ-KiHAf2oTAL_HiHK1MsstBlNgZFCrcJQ&ContentType=png

Example Response
Copy Code

200 OK

Content-Type: image/png

{image data}

Step 5: (Optional) Stop the Session

A Viewing Session may be made unavailable prior to the time it would normally expire with a SessionStopped request. See the API reference for details of what properties can be set for the error response returned for subsequent requests against the stopped session.

Example Request
Copy Code

POST http://localhost:18681/PCCIS/V1/ViewingSession/u-gchUEYvBE5OCgcWJajgoXcW7QD0I8zNDFlexD9hzbXkmrYlw8DrxJ-KiHAf2oTAL_HiHK1MsstBlNgZFCrcJQ/Notification/SessionStopped

Example Response
Copy Code

200 OK