Technical FAQs

Question

We are adding files to the viewing session with HttpWebRequests. We noticed with larger files the response is:

(413) Request Entity Too Large. -  at System.Net.HttpWebRequest.GetResponse(). 

What could be the cause?   

Answer

A 413 request entity too large error occurs when a request made from a client is too large to be processed by the web server. If your web server is setting a particular HTTP request size limit, clients may come across a 413 request entity too large response. An example request that may cause this error would be if a client was trying to upload a large file to the server (e.g., a large media file).

Depending on which web server you use, implement the necessary changes described below to configure your web server’s maximum HTTP request size allowance. Below are some suggestions for popular Web Servers:

For Nginx users:

The directive that determines the allowable HTTP request size is client_max_body_size. This directive can be defined in your nginx.conf file located at /etc/nginx/nginx.conf

For Apache users:

The directive is LimitRequestBody which can be defined in your http.conf file or in an .htaccess file.

For IIS users:

  1. Open Internet Information Services (IIS) Manager.
  2. In the Connections pane, go to the connection, site, application, or directory for which you want to modify your request filtering settings.
  3. In the Home pane, double-click Request Filtering.
  4. Click Edit Feature Settings in the Actions pane.
Question

Can I make a feature request?

Answer

Yes. You can submit your request here by clicking “Add a new Idea”.

Question

Why am I receiving a 500 error when making a Viewing Session PUT request?

Answer

This issue can occur if you forget to prefix the {viewingSessionId} portion of the URL with u, or if you simply request an invalid {viewingSessionId} in the call.

For example, the PUT call should look like the following:

PUT /ViewingSession/u{viewingSessionId}/SourceFile

For more information on syntax and other API calls related to Viewing sessions, please see:

https://help.accusoft.com/PrizmDoc/latest/HTML/webframe.html#pas-viewing-sessions.html

developer sitting at computer

Offering product integrations can be one of the easiest ways to expand the feature set of a product without adding loads of time and cost on development resources. Docubee currently has external integrations with Salesforce, Sharepoint, and Brother scanners that we offer to our customers. Internally, we have an integration with Slack that allows our development team to be notified of different events that happen within Docubee. As a team of engineers, we are always looking for new ways that we could possibly use Docubee with other products, and luckily, we usually find some time to prototype out these integrations.

Being an Apple enthusiast myself, one of the first things I wanted to try to integrate Docubee with was Apple HomeKit so I could use Siri to launch workflows. I configured my Apple TV to work with the Home app and was all ready to go. Unfortunately, I quickly found out that HomeKit does not natively support customizations like this. Lucky for me, someone had already come up with a solution to this problem using Homebridge and a node module called homebridge-cmdswitch2.

According to their Github, Homebridge is “a lightweight NodeJS server you can run on your home network that emulates the iOS HomeKit API” and homebridge-cmdswitch2 “allows you to run Command Line Interface (CLI) commands via HomeKit”. After that, the setup was pretty simple to get everything working. I had to create a workflow in Docubee that I wanted to start, configure my Home app to work with Homebridge, and write this config file below. Before I knew it, Siri was launching workflows for me.

{
  "bridge": {
      "name": "Homebridge",
      "username": "CC:22:3D:E3:CE:30",
      "pin": "031-45-154"
  },
  
  "description": "Homebridge Docubee Config",

  "accessories": [],

  "platforms": [{
    "platform": "cmdSwitch2",
    "name": "CMD Switch",
    "switches": [{
      "name" : "Docubee Workflow",
      "on_cmd": "curl -d '{\"wfModelId\":\"ec6e7fc4-1c38-4ebf-8a32-a02ba6721ffe\", \"wfData\": {}}' -H \"Content-Type: application/json\" -X POST {LAUNCH_WORKFLOW_ENDPOINT}",
      "state_cmd": "exit 1",
      "off_cmd": "echo off"
    }]
 }]
}

One of the next integrations I wanted to try to play with was Slack. I mentioned that we already use it internally, but I wanted to see if there was a way that we could make a Slack integration that was useful for an end-user. After creating my own Slack app to play with, I wanted to be able to launch a workflow from Slack as well as send a message back to Slack notifying me that a workflow was launched. To do both of these things, I had to create a handler somewhere to take the callback IDs that Slack would send to our API and do something with them. The finished handler looked like this:

'use strict';
const qs = require('qs');
const request = require('request')

function handleInteractiveMessage(req, res) {
  const task = req.task;
  res.status(200);
  res.end();
  task.log.info({ source: 'slack-connector.handInteractiveMessage' }, qs.parse(req.body));
  const payload = JSON.parse(qs.parse(req.body).payload);
  const responseUrl = payload.response_url;
  const callbackId = payload.callback_id;
  task.log.info({ source: 'slack-connector.handleInteractiveMessage', responseUrl }, 'response url');
  task.log.info({ source: 'slack-connector.handleInteractiveMessage', callbackId }, 'callback id');
  if (payload.callback_id === 'docubee_workflow_start') {
    kickOffWorkflow(task);
  } else if (payload.callback_id === 'handle_workflow_actions' && payload.actions[0].value !== 'redirect') {
    confirmCancelWorkflow(task, responseUrl, payload.actions[0].value);
  } else if (payload.callback_id === 'confirm_cancel_workflow' && payload.actions[0].value !== 'No') {
    cancelWorkflow(task, payload.actions[0].value, responseUrl)
  }
}

function confirmCancelWorkflow(task, responseUrl, wfInstanceId) {
  return new Promise((resolve, reject) => {
    task.log.info({ source: 'slack-connector.confirmCancelWorkflow', wfInstanceId }, 'wf instance id');
    request({
      url: responseUrl,
      method: 'POST',
      json: true,
      body: {
        text: 'Are you sure you want to cancel this workflow?',
        attachments: [
          {
            fallback: 'See what\'s going on!',
            author_name: 'Owner: ntorretti',
            title: 'Confirm Cancel',
            text: 'Please confirm you want to cancel this workflow',
            callback_id: 'confirm_cancel_workflow',
            actions: [
              {
                name: 'action',
                type: 'button',
                text: 'Yes',
                style: '',
                value: wfInstanceId
              },
              {
                name: 'action',
                type: 'button',
                style: '',
                text: 'No',
                value: 'No'
              }
            ]
          }
        ]
      }
    }, (err, response) => {
      if (err) {
        task.log.error({ source: 'slack-connector.confirmCancelWorkflow', err }, 'whoops');
        reject(err);
      } else {
        task.log.info({ source: 'slack-connector.confirmCancelWorkflow', response }, 'response');
        resolve({ status: 'Request successfully sent to callback API endpoint.' });
      }
    });
  });
}

function sendCancelConfirmation(task, responseUrl) {
  return new Promise((resolve, reject) => {
    request({
      url: responseUrl,
      method: 'POST',
      json: true,
      body: {
        text: 'We have successfully cancelled your workflow.',
      }
    }, (err, response) => {
      if (err) {
        task.log.error({ source: 'slack-connector.sendCancelConfirmation', err }, 'whoops');
        reject(err);
      } else {
        task.log.info({ source: 'slack-connector.sendCancelConfirmation', response }, 'response');
        resolve({ status: 'Request successfully sent to callback API endpoint.' });
      }
    });
  });
}

function cancelWorkflow(task, wfInstanceId, responseUrl) {
  return new Promise((resolve, reject) => {
    request({
      headers: { 'content-type': 'application/json' },
      url: {CANCEL_WORKFLOW_ENDPOINT},
      method: 'POST'
    }, (err, response) => {
      if (err) {
        task.log.error({ source: 'slack-connector.cancelWorkflow', err }, 'whoops');
        reject(err);
      } else {
        task.log.info({ source: 'slack-connector.cancelWorkflow', response }, 'yay');
        sendCancelConfirmation(task, responseUrl);
        resolve(response);
      }
    });
  });
}

function kickOffWorkflow(task) {
  return new Promise((resolve, reject) => {
    request({
      headers: { 'content-type': 'application/json' },
      url: {LAUNCH_WORKFLOW_ENDPOINT},
      method: 'POST',
      body: JSON.stringify({
        wfModelId: 'd32aa8ba-f153-46b5-8c62-81d14327c924',
        wfInstanceName: 'Untitled',
        wfData: {
          Originator: 'Natalie Torretti',
          Originator_Email: 'ntorretti@accusoft.com',
          email: 'ntorretti@accusoft.com'
        }
      }),
    }, (err, response) => {
      if (err) {
        task.log.error({ source: 'slack-connector.handleInteractiveMessage', err }, 'whoops');
        reject(err);
      } else {
        task.log.info({ source: 'slack-connector.handleInteractiveMessage', response }, 'yay');
        resolve(response);
      }
    });
  });
}

module.exports.initialize = (params, imports, ready) => {
  const framework = imports['prv-common-service-base'];
  const task = framework.taskLogging.createTask();
  const server = imports.server;

  task.begin('Initializing Slack connector component');

  server.post('/interactiveMessage', handleInteractiveMessage);

  task.log.info({ source: 'slack-connector.initialize' }, 'Slack connector component initialized');
  task.end();
  ready();
};

Slack has some great documentation and really is built to handle these kind of integrations. It was not that much work to get everything configured after I had the connector in place. I still needed one more piece of code on the Docubee end to be able to actually send the message to Slack. That send message function ended up looking like this:

const sendSlackMessage = imports => (task, redirectUrl, workflowInstanceId, message) => {
  return new Promise((resolve, reject) => {
    task.log.info({ source: 'utils.sendSlackMessage' }, 'sending slack message');
    request({
      url: 'https://hooks.slack.com/services/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',
      method: 'POST',
      json: true,
      body: {
        text: JSON.stringify(message),
        attachments: [
          {
            fallback: 'See what\'s going on!',
            author_name: 'Owner: ntorretti',
            title: 'Workflow Actions',
            text: 'Here are some actions you can take!',
            callback_id: 'handle_workflow_actions',
            actions: [
              {
                name: 'action',
                type: 'button',
                text: 'View dashboard',
                style: '',
                value: 'redirect',
                url: {LINK_URL}
              },
              {
                name: 'action',
                type: 'button',
                text: 'Go to workflow',
                style: '',
                value: 'redirect',
                url: redirectUrl
              },
              {
                name: 'action',
                type: 'button',
                style: '',
                text: 'Cancel Workflow',
                value: workflowInstanceId
              }
            ]
          }
        ]
      }
    }, (err, response) => {
      if (err) {
        task.log.error({ source: 'utils.sendSlackMessage', err }, 'whoops');
        reject(err);
      } else {
        task.log.info({ source: 'utils.sendSlackMessage', response }, 'response');
        resolve({ status: 'Request successfully sent to callback API endpoint.' });
      }
    });
  });
}

We called this the send SlackMessage function after the “Start Demo Workflow” was started. This sends a message back to Slack that gives the user a couple different actions that they could take on that message. If a user clicked one of the buttons in the message, a request with a specific callback ID was sent to the slack handler and the appropriate action was taken. The first image below shows how I integrated starting a workflow in Slack and the second image shows the message we sent back to Slack after a workflow was started giving the user different actions they can take.

These are just a few ways that Accusoft’s Docubee can be integrated into your daily routines. Whether it’s starting a workflow with Siri or enabling automated Slack processes, Docubee is built to help you and your organization to find the best way to automate processes.

Natalie Torretti

Natalie Torretti, Software Engineer III

Natalie joined Accusoft as a software engineer in 2016. She started on the eDocr team but has spent the last two and a half years on Docubee development team. Natalie has been a large contributor to the React front-end UI of Docubee and made several enhancements to the back-end microservices as well. She obtained her B.S. in Biobehavioral Health with a Psychology minor from Penn State as well as her A.S.T. in Information Technology from South Hills School of Business and Technology. When Natalie is not writing code she enjoys working out, spending time at the pool, and playing with her dogs.

Question

What is the proper way of using affinity tokens in cluster mode where multiple file IDs using multiple affinity tokens need to be combined?

Answer

If you are using PrizmDoc Server in cluster (multi-server) mode, and you are using Content Conversion Services to merge multiple files into one, or whenever multiple file ids using multiple affinity tokens need to be combined; your requests need to use a single affinity token. Because affinity tokens need to go in the header, you might think you are required to include all/both of the files’ affinity tokens in the header.

If you find yourself in this situation, the correct method is to re-use the first affinity token you get for all subsequent resources you create. For example, if you create a work file, you’ll get an affinity token back in the response. That affinity token needs to be set in the Accusoft-Affinity-Token request header of any subsequent resources (work files, content converter, viewing sessions, etc.) that you create later and want to use together.

An example is located here:

https://help.accusoft.com/PrizmDoc/latest/HTML/affinity-tokens-and-cluster-mode.html

The main takeaway here is that the initial request that is made to the server for a workfile will return an affinity token. This very same affinity token must be used in the header Accusoft-Affinity-Token for all subsequent requests in this conversion/stitching process.

The most relevant quote from that page is:

“In cluster mode, the PrizmDoc Server API will automatically generate an affinity token when it receives a POST request for a new ViewingSession, WorkFile, MarkupBurner, RedactionCreator, or ContentConverter resource and return it in the response. Once you have obtained an affinity token, you will need to pass this in with related requests using the Accusoft-Affinity-Token HTTP custom header.”

Here is a separate custom example of stitching two TIFF images together by converting them to a PDF.

First TIFF image

Request with no affinity token:

POST /PCCIS/V1/WorkFile HTTP/1.1
Host: prizmdocservername:18681
Content-Type: application/octet-stream

Response:

{
    "fileId": "I3GRFEfrw_K8fX4VJ7Z1bQ",
    "fileExtension": "tif",
    "affinityToken": "ZSTudgjA42h1CVCj0KkGuYiKn5nEFhmFrvA0AkMxDxc="
}

Second TIFF image

Request:

POST /PCCIS/V1/WorkFile HTTP/1.1
Host: prizmdocservername:18681
Content-Type: application/octet-stream
Accusoft-Affinity-Token: ZSTudgjA42h1CVCj0KkGuYiKn5nEFhmFrvA0AkMxDxc=

Response:

{
    "fileId": "I-CTRdFnaL8FLNQDUawTHw",
    "fileExtension": "tif",
    "affinityToken": "ZSTudgjA42h1CVCj0KkGuYiKn5nEFhmFrvA0AkMxDxc="
}

Content Conversion

Request:

POST /v2/contentConverters HTTP/1.1
Host: prizmdocservername:18681
Content-Type: application/json
Accusoft-Affinity-Token: ZSTudgjA42h1CVCj0KkGuYiKn5nEFhmFrvA0AkMxDxc=

{
    "input": {
        "sources": [
            { 
                "fileId": "I3GRFEfrw_K8fX4VJ7Z1bQ"
            },
            { 
                "fileId": "I-CTRdFnaL8FLNQDUawTHw"
            }
        ],
        "dest": {
            "format": "pdf"
        }
    }
}

Response:

{
    "input": {
        "dest": {
            "format": "pdf",
            "pdfOptions": {
                "forceOneFilePerPage": false
            }
        },
        "sources": [
            {
                "fileId": "I3GRFEfrw_K8fX4VJ7Z1bQ",
                "pages": ""
            },
            {
                "fileId": "I-CTRdFnaL8FLNQDUawTHw",
                "pages": ""
            }
        ]
    },
    "expirationDateTime": "2018-10-03T19:12:52.005Z",
    "processId": "1u6k5Y_l7yRfhWyfL1t4Yw",
    "state": "processing",
    "percentComplete": 0,
    "affinityToken": "ZSTudgjA42h1CVCj0KkGuYiKn5nEFhmFrvA0AkMxDxc="
}

Content Conversion Request:

/v2/contentConverters/{processId}

GET /v2/contentConverters/1u6k5Y_l7yRfhWyfL1t4Yw HTTP/1.1
Host: prizmdocservername:18681
Accusoft-Affinity-Token: ZSTudgjA42h1CVCj0KkGuYiKn5nEFhmFrvA0AkMxDxc=

Content Conversion Complete Response:

{
    "input": {
        "dest": {
            "format": "pdf",
            "pdfOptions": {
                "forceOneFilePerPage": false
            }
        },
        "sources": [
            {
                "fileId": "I3GRFEfrw_K8fX4VJ7Z1bQ",
                "pages": ""
            },
            {
                "fileId": "I-CTRdFnaL8FLNQDUawTHw",
                "pages": ""
            }
        ]
    },
    "expirationDateTime": "2018-10-03T19:12:52.005Z",
    "processId": "1u6k5Y_l7yRfhWyfL1t4Yw",
    "state": "complete",
    "percentComplete": 100,
    "output": {
        "results": [
            {
                "fileId": "tK4UbzryHWFoqOC6JJAjAg",
                "sources": [
                    {
                        "fileId": "I3GRFEfrw_K8fX4VJ7Z1bQ",
                        "pages": "1"
                    },
                    {
                        "fileId": "I-CTRdFnaL8FLNQDUawTHw",
                        "pages": "1"
                    }
                ],
                "pageCount": 2
            }
        ]
    }
}

Download The WorkFile:

/PCCIS/V1/WorkFile/{fileId}

GET /PCCIS/V1/WorkFile/1u6k5Y_l7yRfhWyfL1t4Yw HTTP/1.1
Host: prizmdocservername:18681
Accusoft-Affinity-Token: ZSTudgjA42h1CVCj0KkGuYiKn5nEFhmFrvA0AkMxDxc=
Question

Why is the searchTasks endpoint returning an invalid JSON from very large requests?

Answer

Though no official size limit has been published, PAS will return a misleading invalid JSON error if you send in several thousand search terms at once. The exact maximum seems to vary across different installs. We have logged a story in our backlog about making a more explicit size limit possible, but there is no current plan to allow for PrizmDoc to handle search requests of unbounded size.

The best workaround for this behavior is to split your search terms between multiple requests, rather than packing them into one request.

developers sitting at computer

Docubee is a great no-code platform for automating your business processes. If you are a developer, we offer several ways to integrate Docubee directly into your site with straightforward APIs, and a few lines of code. If that isn’t your speed, no worries! You can learn more about how you can use Docubee code free here. Otherwise, read on!

You’ve got your perfect website and your customers know and love your unique style. With Docubee, it’s easy to use your own forms to collect data and much more. With additional effort, you could even send documents hosted on your site to Docubee and auto-populate them with data collected in a form.

To demonstrate a very simple use-case, here is a survey form in Docubee which can be used to collect and track response data. The Docubee workflow will be a very simple two step process – a web form and email step. Check out how to create a workflow template here.

 


The Docubee Workflow

Using Docubee’s fast form creator, it was easy to create a simple survey form.

Once created and published, the workflow’s form can be directly linked via URL for collecting survey data, or it can be submitted from your own site by initiating a POST request. This way you don’t need to worry about storing the data. Docubee allows you to track and export all responses.

Each field in the workflow designer has a Field Label and Property Name. The label is what shows up on the Docubee web form, and the Property Name is what the response data corresponds with in the Docubee dashboard.

So far, there are six “Single-Line Text” fields on the form, five of which have a data type of text and one of type e-mail.

(Label / Property Name)

  • What is your favorite product? / Favorite_Product
  • Why did your purchase this product? / Why_Purchase_Product
  • How satisfied are you with this product? / Product_Satisfaction
  • Would you recommend this product to a friend? / Recommend_Product
  • Would you recommend this company to a friend? / Recommend_Company
  • Your Email / Respondent_Email

The property name is also how the data is stored in the POST request body to Docubee that initiates the workflow.


The Docubee API

The workflow can be initiated from your site by having your form post to custom route on your server. The handler behind that route needs to format your forms response data to POST to the workflow instances API endpoint:

POST - https://docubee.app/api/v1/workflowInstances
Content-Type: application/json
Request Body
{
  "wfModelId": "yourModelIdHere",
  "wfData": {
    "Favorite_Product": "yourDataHere",
    "Why_Purchase_Product": "yourDataHere",
    "Product_Satisfaction": "yourDataHere",
    "Recommend_Product": "yourDataHere",
    "Recommend_Company": "yourDataHere",
    "Respondent_Email": "yourDataHere"
  }
}
Response
Content-Type: application/json
{
  "wfInstanceId": "instance-id",
  "redirectUrl": "url-if-there-is-a-next-workflow-step"
}

After a successful POST request, the workflow will be initiated with the data and a thank you email would be automatically sent to the email contained in the “Respondent_Email” property.

The survey responses can be tracked in the Docubee Dashboard under the “COMPLETED” instances tab.

All survey results can also be exported to a CSV file using the “Export Workflows” button.

 

 

Example CSV Export:

Docubee can be used for a wide variety of different use cases, from something as simple as collecting survey data, to more advanced use-cases requiring documents hosted on your site to be automatically populated with data.

Reach out today to schedule a demo, or to get started integrating Docubee’s other powerful APIs into your product. For more advanced use-cases our Professional Services team would be more than happy to assist.

Check out more here.

Landon Lamb

Landon Lamb, Software Engineer III – Docubee Team

Landon started out as a Software Engineer in Support at Accusoft in July 2016. In April of 2017, he transitioned onto the Docubee team initially as a Workflow Developer.

Currently, Landon is a Software Engineer III and works on the front end site, the back end services, and the product’s build pipeline. He enjoys helping deliver new features to Docubee’s growing user base.

Question

I have EML and MSG files that contain attachments. I want to combine the original EML/MSG document with each of its attachments into a single PDF. How can I do this?

Answer

To do this you are going to need to create a viewing session for the EML or MSG file. Once you’ve created the viewing session you can get the viewingSessionIds of the attachments. Once you have the viewingSessionIds you can get the workFile ID associated with each viewing session. With the workfile IDs you can use the Content Conversion Service (CCS) to combine the email with its attachments into a single PDF.

Use the following API requests to do this:

Create a new viewing session with:

POST {server_base_url}/PCCIS/V1/ViewingSession 

This will give you a viewingSessionId which will be used in future requests.

The body for this request will be JSON:

    {
        "render": {
            "html5": {
                "alwaysUseRaster": false
            }
        }
    }

Upload the document with:

PUT {server_base_url}/PCCIS/V1/ViewingSession/u{viewingSessionId}/SourceFile?FileExtension={extension} 

The request body must be bytes of the source document. Make sure to include the FileExtension or PrizmDoc won’t be able to detect the file as an EML or MSG file.

Poll for and get the viewingSessionIds of the attachments with:

GET {server_base_url}/PCCIS/V1/ViewingSession/u{viewingSessionId}/Attachments

This will return the viewingSessionIds for each of the attachments.

Get the workfile ID for each of the viewing sessions with:

GET {server_base_url}/PCCIS/V1/ViewingSession/u{viewingSessionId}/FileId 

You’ll need to get a fileId for each attachment’s viewingSession and the email’s viewingSession.

With those workfile IDs, you can use the Content Conversion Service (CCS) to combine each of the workfiles with:

POST {server_base_url}v2/contentConverters

The body for this request will be JSON and need to include the workfileId for each of the attachments and the email itself. The body would look like this:

    {
        "input": {
            "sources": [
                { 
                    "fileId": "{EmailWorkFileId}"
                },
                { 
                    "fileId": "{Attachment1WorkFileId}"
                },
                { 
                    "fileId": "{Attachment2WorkFileId}"
                }
                
            ],
            "dest": {
                "format": "pdf"
            }
        }
    }

This will return a processId that you can poll using:

GET /v2/contentConverters/{processId}

Once the process is complete, the request will return a results array that will contain the fileId of the final document.

You can get the final document that contains all the attachments and original EML/MSG file combined into a single PDF with:

GET /PCCIS/V1/WorkFile/{fileId}
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.

Question

How can I get a document’s dimensions with PrizmDoc?

Answer

There are two methods you can use to do this with PrizmDoc:

The first method is using the requestPageAttributes() method from ViewerControl. This method allows you to get the width and height of a page in the document in pixels. Below is sample code on how to use requestPageAttributes() to get the attributes of page 1 of a document:

viewerControl.requestPageAttributes(1).then(function(attributes) {
    var pageWidth = attributes.width;
    var pageHeight = attributes.height;
});

The second method is done by making a GET request to the PrizmDoc server to get metadata for a page of the source document in a viewing session. The request is:

GET /PCCIS/V1/Page/q/{{PageNumber}}/Attributes?DocumentID=u{{viewingSessionId}}&ContentType={{ContentType}}

The content type needs to be set to “png” for raster content and “svgb” for SVG content. The request returns the data in a JSON object containing the image’s width and height. The units for the width and height are in pixels when the contentType is set to “png” and unspecified units when the content type is set to “svgb”.

The request also returns the horizontal and vertical resolution of raster content when the content type is set to “png”. This information is similar to pixels per inch, but the units are unspecified, so if you wanted to calculate the size of the document you can calculate it by width divided by horizontal resolution or height divided by vertical resolution. The resolution is hard-coded to 90 when contentType is set to “svgb”.