PrizmDoc® v14.1 Release - Updated
PrizmDoc / Developer Guide / Get Started with Hybrid Viewing / Create On-Demand Viewing Packages
In This Topic
    Create On-Demand Viewing Packages
    In This Topic

    Overview

    PrizmDoc offers Hybrid Viewing that reduces the load on the server by parsing and rendering documents completely on the client. This means the server is freed up to handle more concurrent users and process more documents.

    NOTE: Using the Hybrid Viewing feature with PDF-only viewing packages requires a Metered License, Offline Metered License or OEM License. After getting a license, refer to the Get Started section in PDF-only Viewing Packages.

    NOTE: Printing is not available for the Hybrid Viewing feature. For a list of additional limitations, refer to getClientRestrictions in the ViewerControl API.

    The pdf type of Viewing Package is specifically designed for Hybrid Viewing. While existing Viewing Packages (including on-demand) will work with Hybrid Viewing, we recommend using the pdf package type because it can be generated faster and requires less storage. See the /v2/ViewingPackageCreators endpoint's packageType parameter for more details.

    How to use Hybrid Viewing

    This section provides instructions on how to use Hybrid Viewing with PrizmDoc:

    Step 1: Create an On-Demand Viewing Package

    First, you need to determine if your application will pre-convert documents (if you have access to them before viewing-time), or if it will perform on-demand viewing (if you don't have access to them before viewing-time).

    In this step, we will create an on-demand Viewing Package through the POST /ViewingSession endpoint in PAS.

    NOTE: This step is creating a Viewing Session, but because the request includes a documentId with the url, it will also create a Viewing Package at the same time. Future Viewing Sessions created using that documentId will be much faster than the first one because they will be created from a Viewing Package with all of the conversions already completed.

    To use Hybrid Viewing, set the allowedClientFileFormats to ['pdf'] in the request body. We're using a PDF in the following example because they are immediately viewable.

    NOTE: You can view any document type supported by PrizmDoc, but Viewing Sessions created for PDF documents and PDF-only Viewing Packages will have the best performance. If you have a non-PDF document that will be viewed in multiple subsequent Viewing Sessions, we recommend creating a Viewing Package with the packageType = ['pdf']. Then, PAS will create a Viewing Package that contains only the PDF.

    Example Request

    POST http://localhost:3000/ViewingSession
    
    Content-Type: application/json
    {
      'source': {
        'type': 'url',
        'url': 'http://example.com/my.pdf',
        'documentId': 'myUniqueIdentifier
      },
      'allowedClientFileFormats': ['pdf']
    }
    
    

    Example Response

    200 OK
    
    Content-Type: application/json
    {
        "viewingSessionId":"-gchUEYvBE5OCgcWJajgoXcW7QD0I8zNDFlexD9hzbXkmrYlw8DrxJ-KiHAf2oTAL_HiHK1MsstBlNgZFCrcJQ"
    }
    
    

    Step 2: Instantiate the Viewer

    Next instantiate the Viewer, providing a documentId with the viewingSessionId value obtained from the POST /ViewingSession call in Step 1 above. See Initial Integration for more details on integrating the Viewer into your application.

    Example Instantiation

    const viewer = $('#viewerContainer').pccViewer({
      documentId: "-gchUEYvBE5OCgcWJajgoXcW7QD0I8zNDFlexD9hzbXkmrYlw8DrxJ-KiHAf2oTAL_HiHK1MsstBlNgZFCrcJQ"
    })
    
    

    Conclusion

    Congratulations, you are now using the Hybrid Viewing feature to view a document!