How do I specify a password for a document using PrizmDoc?

Question

Can PrizmDoc handle password-protected files, such as PDFs or Excel files?
How would a user specify a password for a particular document?

Answer

It is possible to specify the password for a password-protected document when creating a viewing session in PrizmDoc. When sending a request to create a viewing session, you’ll use the password field in the request body to specify the password. For example…

POST http://localhost:3000/ViewingSession
Content-Type: application/json
{
    "source": {
        "type": "url",
        "url": "https://www.usability.gov/sites/default/files/creating-wireframes.pdf"
    },
    "password": "hunter2"
}

(Replace "hunter2" with the actual password)

Please note that even if a file needs a password and is not provided one (or is provided one that’s incorrect), the viewing session should still be created successfully. The easiest method to determine whether the password is needed/correct is to make a call to get the page. You can do this by making a GET request to the GetPage route using the viewingSessionId created earlier, like so…

GET pas_base_url/Page/q/0?DocumentID=u{viewingSessionId}

…be sure to replace pas_base_url with the root of your Prizm Application Services (PAS) instance (usually this is http://localhost:3000) and replace {viewingSessionId} with the actual value for viewingSessionId created in the previous step.

The above call will return 200 OK if the page load is successful. If a password is required/incorrect, you should see a return status code 480. There will be additional response headers called accusoft-status-number and accusoft-status-message, which should be 4001 and "Document requires a password", respectively.

You can see the above in greater detail in the product documentation here.

You can use this information to re-create a viewing session with the correct password.

Currently, there is a feature request planned for a potential future release of PrizmDoc to prompt the user for a password if one is required.