PrizmDoc Viewer v13.23 - Updated
Developer Guide / PrizmDoc Server / How To Examples / Pre-Convert Documents to PDF
In This Topic
    Pre-Convert Documents to PDF
    In This Topic

    Introduction

    "v3" viewing package REST APIs allow you to pre-convert documents of any format supported by PrizmDoc Server to PDF, and store result PDFs for future use with the ability to control their lifetime in the storage.

    NOTE: These APIs are not for use with the PrizmDoc Viewer Client. If you need to pre-convert a document for the PrizmDoc Viewer client, use the PAS "v2" viewing package creators and viewing packages REST APIs instead (see Work with Viewing Packages in the PAS Developer Guide for more information).

    NOTE: The "v3" viewing packages and viewing package creators REST APIs are currently only available for on-premise deployments.

    NOTE: This feature is disabled by default. See Enable Pre-Conversion to PDF on how to configure this feature.

    The following steps walk you through using the PrizmDoc Server REST API to pre-convert documents.

    Step 1: Upload Your Source Document

    • Upload the source document that you want to pre-convert to PDF.
    • In response to this request, you will receive a file ID that is used to reference the source document in later requests.
    • See the Work Files API for more details about this request.

      Example

       POST /PCCIS/V1/WorkFile?FileExtension=docx
       Content-Type: application/octet-stream
       [binary data]
      
        200 OK
        Content-Type: application/json
        {
            "fileId": "rxpuVUxMFWzAZFUmQ6fmYA",
        }
      
      

    Step 2: Start the "v3" Viewing Package creation

    • Start the viewing package creation process, specifying the file ID of the source document, obtained in the previous step, and your own unique identifier for the new viewing package.
    • In response to this request, you will receive a Viewing Package Creator process ID that is used to track the viewing package creation process.
    • See the "v3" Viewing Package Creators API for more details about this request.

      Example

       POST /v3/viewingPackageCreators
       Content-Type: application/json
      
       {
         "input": {
           "packageId": "MyPackage_IHN0YXJzaGlwIE5vc3Ryb21v",
           "source": {
             "type": "workFile",
             "fileId": "rxpuVUxMFWzAZFUmQ6fmYA"
           },
           "lifetimeAfterLastUse": "30d"
         }
       }
      
       HTTP 200 OK
       Content-Type: application/json
      
       {
           "input": {
               "packageId": "MyPackage_IHN0YXJzaGlwIE5vc3Ryb21v",
               "source": {
                   "type": "workFile",
                   "fileId": "rxpuVUxMFWzAZFUmQ6fmYA"
               },
               "lifetimeAfterLastUse": "30d"
           },
           "expirationDateTime": "2021-09-13T10:58:15.551Z",
           "percentComplete": 0,
           "processId": "_wDAkhncr8_2PUWJc3Vfdw",
           "state": "processing"
       }
      
      

    Step 3: Check Status of the "v3" Viewing Package Creator Resource

    • The process to convert your source document to PDF runs asynchronously on the PrizmDoc Server. The POST request you sent in Step 2 will return immediately and before the output is ready. This means you will need to check the status of the process by sending a GET request to the resource you just created.
    • In response to this request, JSON will be returned that includes a state property. When this property is "complete", you can proceed to the next step.
    • See the "v3" Viewing Package Creators API for more details about this request.

      Example

      GET /v3/viewingPackageCreators/_wDAkhncr8_2PUWJc3Vfdw
      
      HTTP 200 OK
      Content-Type: application/json
      
      {
          "input": {
              "packageId": "MyPackage_IHN0YXJzaGlwIE5vc3Ryb21v",
              "source": {
                  "type": "workFile",
                  "fileId": "rxpuVUxMFWzAZFUmQ6fmYA"
              },
              "lifetimeAfterLastUse": "30d"
          },
          "percentComplete": 100,
          "expirationDateTime": "2021-09-13T10:58:15.000Z",
          "processId": "_wDAkhncr8_2PUWJc3Vfdw",
          "state": "complete"
      }
      
      

    Step 4 (optional): Check Status of the "v3" Viewing Package

    • This step might be useful if you created the viewing package, did not use it for a while, and want to make sure the package has not expired yet.
    • See the "v3" Viewing Packages API for more details about this request.

    Example

       GET /v3/viewingPackages/MyPackage_IHN0YXJzaGlwIE5vc3Ryb21v
    
       HTTP 200 OK
       Content-Type: application/json
    
       {
        "expirationDateTime": "2021-10-13T10:38:17.000Z",
        "creationDateTime": "2021-09-13T10:38:15.000Z",
        "bytes": 6145,
        "lifetimeAfterLastUse": "30d"
       }
    
    

    Step 5: Get PDF Contents of the "v3" Viewing Package

    • Download the PDF representation of the original document used to create the viewing package.
    • See the "v3" Viewing Packages API for more details about this request.

      Example

      GET /v3/viewingPackages/MyPackage_IHN0YXJzaGlwIE5vc3Ryb21v/content/pdf
      
      HTTP 200 OK
      Content-Type: application/pdf
      
      <PDF file bytes>