Technical FAQs

Question

How can I enable content encryption in PrizmDoc Viewer?

Answer

First, you need to enable content encryption on the PrizmDoc Server in the central configuration file. To do this, find the viewing.contentEncryption.enabled section and change the value to true. Save the changes to the file and restart the PrizmDoc services for the change to take effect.

The file paths for the central configuration file are:

Linux: /usr/share/prizm/prizm-services-config.yml
Windows: C:\Prizm\prizm-services-config.yml

Next, you need to enable content encryption in the Viewer. To do this, in the index page of your viewer (Default.aspx in C#, index.php in the PHP sample, index.html, etc.), provide the encryption option in the viewer options parameter as follows so that the Viewer can handle encrypted data:

function buildViewerOptions() {
    ...
    var optionsOverride = args.pop(); // always last arg
    var options = {
        ...
        encryption: true
    };
    var combinedOptions = _.extend(optionsOverride, options);
    embedViewer(combinedOptions);
}

For more in-depth information on enabling content encryption in PrizmDoc, please refer to our documentation here.

Question

When doing a text search in a document in PrizmDoc, the highlight color for the search results is a light blue background. Is there a way to change the highlight color for search results in the PrizmDoc Viewer?

Answer

You can change the highlight color specifically in the PrizmDoc Viewer file viewer.js file located in the viewer-assets\js folder of your project/application.

You will need to locate 2 instances of the search term “highlightColor: undefined” in the code block below located close to line 4400. The actual line number will vary depending on the version of viewer.js you are using. You can replace “undefined” with a hexadecimal color value which you can look up from the following site: https://htmlcolorcodes.com/

// This is a request for a new searchQuery triggered by the search input field.
// Generate new search terms, and save them globally.
prevMatchingOptions = _.clone(matchingOptions);

if (matchingOptions.exactPhrase) {
    // We need to match the exact string, as is
    if (queryString.length) {
        searchTerms.push({
            searchTerm: queryString,
            highlightColor: undefined,
            searchTermIsRegex: false,
            contextPadding: 25,
            matchingOptions: matchingOptions
        });
    }
} else {
    // Split up multiple words in the string into separate search term objects
    var queryArr = queryString.split(' ');
    queryArr = _.unique(queryArr);
    _.forEach(queryArr, function(query){
        if (query.length) {
            searchTerms.push({
                searchTerm: query,
                highlightColor: undefined,
                searchTermIsRegex: false,
                contextPadding: 25,
                matchingOptions: matchingOptions
            });
        }
    });
}         
Question

How can I change the PrizmDoc Viewer so that the TextSelection tool is selected by default instead of the Pan tool?

Answer

In order to select the TextSelection tool by default in PrizmDoc Viewer there are a few things you need to take into account. First, you have to click the button inside the embedViewer() function found in the index page of the sample. Second, the button for the text selection tool is actually disabled initially, so in order to be able to click it, the button has to be enabled first by removing the pcc-disabled class.

Use the following code to do this:

function embedViewer(options) {
    var viewer = $('#viewer1').pccViewer(options);
    viewer.viewerControl.on(PCCViewer.EventType.ViewerReady, function(viewer) {
        $("[data-pcc-mouse-tool=\"AccusoftSelectText\"]").removeClass('pcc-disabled');
        $("[data-pcc-mouse-tool=\"AccusoftSelectText\"]").click();            
    });
}
Question

I’m receiving Uncaught ReferenceError: viewLabel is not defined when trying to embed the PrizmDoc Viewer in my web application. What could be the issue?

Answer

This error indicates that the language property in the viewer initialization has not been specified or is undefined.

To fix this, ensure you are loading viewerCustomizations.js.

If the version you are working with predates viewerCustomizations.js, you can get a copy of viewerCustomizations.js from the viewer assets hosted here and update your viewer initialization code.

Question

I’m receiving Uncaught ReferenceError: viewLabel is not defined when trying to embed the PrizmDoc Viewer in my web application. What could be the issue?

Answer

This error indicates that the language property in the viewer initialization has not been specified or is undefined.

To fix this, ensure you are loading viewerCustomizations.js.

If the version you are working with predates viewerCustomizations.js, you can get a copy of viewerCustomizations.js from the viewer assets hosted here and update your viewer initialization code.

Barcode Xpress ImageGear .NET

Barcode Xpress and ImageGear .NET.  Barcode Xpress is a leading barcode reading SDK. While it supports a variety of image formats, Barcode Xpress works with ImageGear to support even more obscure image formats. For example, Barcode Xpress does not support reading barcodes on PDFs. Combined with ImageGear, developers can support a myriad of image formats and PDFs. With Barcode Xpress & ImageGear working together, developers can integrate a barcode reader that can detect barcodes on almost any kind of document.

Barcode Xpress accepts images in multiple different object types, such as System.Drawing.Bitmap. Using the method ImGearFileFormats.ExportPageToBitmap we can easily take any image that ImageGear supports and export it to a System.Drawing.Bitmap object that we can then pass to Barcode Xpress. So, only a tiny amount of code is required to recognize barcodes with ImageGear .NET and Barcode Xpress. Below, we’ll show various ways to pass different types of images and documents to Barcode Xpress.


Image:

// Load the image into the page.
ImGearPage imGearPage = ImGearFileFormats.LoadPage(stream, 0);

// Export the image to a bitmap and pass that bitmap to Barcode Xpress
 Result[] results = barcodeXpress.reader.Analyze(ImGearFileFormats.ExportPageToBitmap(imGearPage));


PDF:

We need slightly more code for a PDF. First, we specify a page number when calling LoadPage. Second, we must dispose of the ImGearPage object after we’re done with it. 

// Load the specified page of the PDF as an ImGearPage object
ImGearPage imGearPDFPage = ImGearFileFormats.LoadPage(stream, pageNumber);

// Export the image to a bitmap and pass that bitmap to Barcode Xpress
Result[] results = barcodeXpress.reader.Analyze(ImGearFileFormats.ExportPageToBitmap(imGearPDFPage));

(imGearPDFPage as IDisposable).Dispose();

Now that we’ve explained the most important part, we’ll show you a simple console app that recognizes barcodes on a PDF using the method above. 

The code below assumes you’ve installed an evaluation or development license for both Barcode Xpress and ImageGear .NET.

using System;
using System.IO;
using Accusoft.BarcodeXpressSdk;
using ImageGear.Core;
using ImageGear.Evaluation;
using ImageGear.Formats;
using ImageGear.Formats.PDF;

namespace BXandIGDotNet
{
	class Program
	{
    	static int pageNumber = 0;
    	static string fileName = @"Path/To/Your/PDF..pdf";
    	static void Main(string[] args)
    	{
        	// Initialize evaluation license.
        	ImGearEvaluationManager.Initialize();

        	// Initialize common formats.
        	ImGearCommonFormats.Initialize();
        	// Add support for PDF and PS files.
        	ImGearFileFormats.Filters.Insert(0, ImGearPDF.CreatePDFFormat());
        	ImGearFileFormats.Filters.Insert(0, ImGearPDF.CreatePSFormat());
        	ImGearPDF.Initialize();

        	using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
        	using (BarcodeXpress barcodeXpress = new BarcodeXpress())
        	{
            	// Load the specified page of the PDF as an ImGearPage object
            	ImGearPage imGearPDFPage = ImGearFileFormats.LoadPage(stream, pageNumber);

            	// Export the image to a bitmap and pass that bitmap to Barcode Xpress
            	Result[] results = barcodeXpress.reader.Analyze(ImGearFileFormats.ExportPageToBitmap(imGearPDFPage));

            	(imGearPDFPage as IDisposable).Dispose();

            	// Print the values of every barcode detected.
            	for (int i = 0; i < results.Length; i++)
            	{
                	Console.WriteLine("#" + i.ToString() + " Value: " + results[i].BarcodeValue);
            	}
            	Console.ReadKey();
        	}
    	}
	}
}

Using Barcode Xpress and ImageGear in Other Languages & Linux

You can also use Barcode Xpress and ImageGear together outside of the .NET framework. Barcode Xpress supports several different programming languages and frameworks including .NET Core, Java, NodeJS, Python, C, and C++. All of which can be used on Linux. 

ImageGear for C/C++ also supports Linux. Barcode Xpress Linux, which is a C/C++ library, ships with a sample called “ReadBarcodesIG”, that shows how to integrate Barcode Xpress Linux and ImageGear for C/C++. You can find the sample code after downloading our SDK here! For more information on Barcode Xpress, visit our Developer Resources page on the website. In addition, you can also find more information about ImageGear .NET on its respective Developer Resources page as well.

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

When selecting download and including annotations, the resulting PDF does not include the comments. How can we obtain the file as a PDF with the annotation comments included?

Answer

By design, when using the download button, the comments to the annotations are not included in the download.

Workaround

  1. Under the View tab, select Print.
  2. From the Print dialog, select the More options drop-down.
  3. Under the Comments section, select either After Each Page or At End of Document.
  4. When selecting a printer, use the Print to PDF option and it will create a PDF with the comments included.
Question

I want the Thumbnail tab in PrizmDoc Viewer to be open by default. How can this be done?

Answer

A simple solution could be to simply implement a ‘click-on-the-button’ when you first open the Viewer, if you’re fine with the user being able to close the thumbnail pane:

$("[data-pcc-toggle=\"dialog-thumbnails\"]").click();

If you’d rather have the tab always open, in viewer.js there’s a function called toggleDialogs(opts) that checks for whether the thumbnail pane is being toggled through the opts.toggleID, and if so, adds openClass to the thumbDialog. You could modify this logic so that the thumbnail pane is permanently open.

Question

With PrizmDoc Viewer, can I have more than a single viewer on the same page?

Answer

Yes, just initialize a second viewer on another <div> in the page. You can use the initialization code here more than once within the same page.

Question

With PrizmDoc Viewer, can I have more than a single viewer on the same page?

Answer

Yes, just initialize a second viewer on another <div> in the page. You can use the initialization code here more than once within the same page.