Technical FAQs

Question

In some other viewers, there are highlights or markers that appear on the UI to indicate that annotations are available for a given page or document. Is there a way to implement this in PrizmDoc?

Answer

Sure can, you just need to make a MarkupLayerRecords request to determine if there are marks that pertain to the given Viewing Session. Keep in mind that documents don’t really have a specific set of annotations associated with them though — Markup IDs do, and you can specify any Markup ID you want when you create a viewing session:

// Add rules to your CSS for the following classes.
// The actual style information can be whatever you like.
//
// .mark-indicator {
//     background-color: gold !important;
// }
//
// .marked-page-indicator {
//     background-color: gold !important;
// }

let pasUrl = "http://localhost/pas-service"; // Example PAS proxy URL
let viewingSessionId = <%= viewingSessionId %>; // Example viewingSessionId
let thumbnailButton = $(".pcc-icon-thumbnails");
let pageIndicatorsAdded = false;
let thumbnailsClicked = false;
let marksRetrieved = false;
let markedPages = {};

async function addPageIndicators() {
    console.log("Attempting to add page indicators...");
    if (thumbnailsClicked && marksRetrieved && !pageIndicatorsAdded) {
        console.log("Conditions met.");

        let wrappers = $(".pccThumbnailWrapper");

        wrappers.each(function(index, wrapper) {
            if (markedPages[index]) {
                $(wrapper).addClass("marked-page-indicator");
            }
        });

        pageIndicatorsAdded = true;
    } else {
        console.log("Conditions not met");
    }
}

thumbnailButton.click(function() {
    console.log("Thumbnails button clicked.");

    thumbnailsClicked = true;

    addPageIndicators();
});

async function apiCall(type, url, body = {}) {
    return await $.ajax({
        "type": type,
        "url": url,
        "contentType": "application/json",
        "data": JSON.stringify(body)
    });
}

async function createMarkIndicators() {
    let output = await apiCall("GET", `${pasUrl}/MarkupLayers/u${viewingSessionId}`);

    if (output.length > 0) {
        console.log("Found layers.");

        thumbnailButton.addClass("mark-indicator");

        let layers = await Promise.all(output.map(function(element) {
            return apiCall("GET", `${pasUrl}/MarkupLayers/u${viewingSessionId}/${element.layerRecordId}`);
        }));

        layers.forEach(function(layer) {
            layer.marks.forEach(function(mark) {
                markedPages[mark.pageNumber - 1] = true;
            });
        });

        marksRetrieved = true;

        console.log("Marks retrieved.");

        addPageIndicators();
    } else {
        console.log("No layers found.");
    }
}

createMarkIndicators(); 
Question

How do I use a Network Drive path for Image and ART storage in my ImageGear .NET web application?

Answer

In an ImageGear .NET web application, you have to define the location of the images and annotations directory in the storageRootPath and artStorageRootPath configuration property.
In the current version of ImageGear .NET, the storageRootPath and artStorageRootPath do not work with a network drive path \\SERVER-NAME\sharefilename.

The workaround for this would be to create a Symbolic link from a local directory to the network drive directory.

  • To create a symbolic link: Open “Command Prompt” as Administrator and type in > mklink /d "local path" \\SERVER-NAME\sharefilename
  • Pass in the path of the symbolic link as image or art storage root path in your web.config: storageRootPath="local path" artStorageRootPath="local path"
Question

How do I use a Network Drive path for Image and ART storage in my ImageGear .NET web application?

Answer

In an ImageGear .NET web application, you have to define the location of the images and annotations directory in the storageRootPath and artStorageRootPath configuration property.
In the current version of ImageGear .NET, the storageRootPath and artStorageRootPath do not work with a network drive path \\SERVER-NAME\sharefilename.

The workaround for this would be to create a Symbolic link from a local directory to the network drive directory.

  • To create a symbolic link: Open “Command Prompt” as Administrator and type in > mklink /d "local path" \\SERVER-NAME\sharefilename
  • Pass in the path of the symbolic link as image or art storage root path in your web.config: storageRootPath="local path" artStorageRootPath="local path"
Question

I’m receiving the error “Uncaught TypeError: Cannot read property ‘viewer’ of undefined” when trying to embed the PrizmDoc Viewer in my web application. What could be the issue?

Answer

This indicates that the template 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

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

I’m receiving the error “Uncaught TypeError: Cannot read property ‘viewer’ of undefined” when trying to embed the PrizmDoc Viewer in my web application. What could be the issue?

Answer

This indicates that the template 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.

OCR segmentation

Today’s high-speed forms processing workflows depend on accurate character recognition to capture data from document images. Rather than manually reviewing forms and entering data by hand, optical character recognition (OCR) and intelligent character recognition (ICR) allow developers to automate the data capture process while also cutting down on human error. Thanks to OCR segmentation, these tools are able to read a wide range of character types to keep forms workflows moving efficiently.

Recognizing Fonts

Deploying OCR to capture data is a complex undertaking due to the immense diversity of fonts in use. Modern character recognition software focuses on identifying the pixel patterns associated with specific characters rather than matching characters to existing libraries. This gives them the flexibility needed to discern multiple font types, but problems can still arise due to spacing issues that make it difficult to tell where one character ends and another begins.

Fonts generally come in one of two forms that impact how much space each character occupies. “Fixed” or “monospaced” fonts are uniformly spaced so that every character takes up the exact same amount of space on the page. While not quite as popular now in the era of word processing software and digital printing, fixed fonts were once the standard form of typeface due to the technical limitations of printing presses and typewriters. On a traditional typewriter, for example, characters were evenly spaced because each typebar (or striker) was a standardized size.

From an OCR standpoint, fixed fonts are easier to read because they can be neatly segmented. Each segmented character is the same size, no matter what letters, numbers, or symbols are used. In the example below, the amount of space occupied by the characters is determined by the number of characters used, not the shape of the characters themselves. This makes it easy to break the text down into a segmented grid for accurate recognition.

OCR segmentation:  Monospace Font Example

“Proportional” fonts, however, are not uniformly spaced. The amount of space taken up by each character is determined by the shape of the character itself. So while a w takes up the same space as an i in a fixed font, it takes up much more space in a proportional font.

OCR segmentation:  Fixed versus proportional font

The inherent characteristics of proportional fonts makes them more difficult to segment cleanly. Since each character occupies a variable amount of space, each segmentation box needs to be a different shape. In the example below, applying a standardized segmentation grid to the text would fail to cleanly separate individual characters, even though both lines feature the exact same character count.

Proportional Font Example

Yet another font challenge comes from “kerning,” which reduces the space between certain characters to allow them to overlap. Frequently used in printing, kerning makes for an aesthetically pleasing font, but it can create serious headaches for OCR data capture because many characters don’t separate cleanly. In the example below, small portions of the W and the A overlap, which could create confusion for an OCR engine as it analyzes pixel data. While the overlap is very slight in this example, many fonts feature far more extreme kerning.

Example of Kerning

In order to get a clean reading of printed text for more accurate recognition results, OCR engines like the one built into Accusoft’s SmartZone SDK utilize segmentation to take an image and split it into several smaller images before applying recognition. This allows the engine to isolate characters from one another to get a clean reading without any stray pixels that could impact recognition results.

Much of this process is handled automatically by the software. SmartZone, for instance, has OCR segmentation settings and properties that are handled internally based on the image at hand. In some cases, however, those controls may need to be adjusted manually to ensure the highest level of accuracy. If a specific font routinely returns failed or low confidence recognition results, it may be necessary to use the OCR segmentation properties to adjust for font characteristics like spaces, overlaps (kerning), and blob size (which distinguishes which pixels are classified as noise).

Applying ICR Segmentation

All of the challenges associated with cleanly segmenting printed text are magnified when it comes to hand printed text. Characters are rarely spaced or even shaped consistently, especially when they’re drawn without the guidance of comb lines that provide clear separation for the person completing a form.

Since ICR engines read characters as individual glyphs, they can become confused if overlapping characters are interpreted as a single glyph. In the example below, there is a slight overlap between the A and the c, while the cross elements of the f and t are merged to form the impression of a single character.

ICR Segmentation Properties

SmartZone’s ICR segmentation properties can be used to pull apart overlapping characters and split merged characters for more accurate recognition results. This is also important for maintaining a consistent character count. If the ICR engine isn’t accounting for overlapped and merged characters, it could return fewer character results than are actually present in the image.

Enhance Your Data Forms Capture with SmartZone

Accusoft’s SmartZone SDK supports both zonal and full page OCR/ICR for forms processing workflows to quickly and accurately capture information from document images. When incorporated into a forms workflow and integrated with identification and alignment tools like the ones found in FormSuite, users can streamline data capture and processing by extracting text and routing it to the appropriate databases or application tools. SmartZone’s OCR supports 77 distinct languages from around the world, including a variety of Asian and Cyrillic characters. For a hands-on look at how SmartZone can enhance your data capture workflow, download a free trial today.

 

SmartZone powershell
 

Continuous innovation has allowed Accusoft to build sustained success over the course of three decades. Much of that innovation comes from talented developers creating novel solutions to everyday problems, many of which go on to become patented technologies that provide the company with an edge over competitors. 

Others, however, are the byproduct of looking at problems from a different perspective or using existing technologies in unique ways. Accusoft supports both approaches by hosting special “hackathon” events each year. These events encourage developers to spend time working on their own unique projects or try out ideas they think may have potential but have never been implemented.

For this year’s hackathon, I took a closer look at how our SmartZone SDK could be implemented as part of an automation solution within a .NET environment without creating an entire application from the ground up. What I discovered was that PowerShell modules offer a quick and easy way to deploy character recognition for limited, unique use cases.

.NET and PowerShell

One of the underestimated abilities of the .NET infrastructure is support loading and executing assemblies out of box from the command line using a shell module. Although there are many shell variants available, PowerShell comes preinstalled on most Windows machines and is the only tool required to make the scripts and keep them running. PowerShell also runs on Linux and macOS, which makes it a true cross-platform task automation solution for inventive developers who crave flexibility in their scripting tools. 

Incorporating the best features of other popular shells, PowerShell consists of a command-line shell, a scripting language, and a configuration management framework. One of the unique features of PowerShell, however, is that unlike most shells which can only accept and return text, it can do the same with .NET objects. This means PowerShell modules can be used to build, test, and deploy solutions as well as manage any technology as part of an extensible automation platform.

Implementing SmartZone Character Recognition

Accusoft’s SmartZone technology allows developers to incorporate advanced zonal character recognition to capture both machine-printed and hand-printed data from document fields. It also supports full page optical character recognition (OCR) and allows developers to set confidence values to determine when manual review of recognition results are necessary. 

Implementing those features into an application through a third-party integration is the best way to incorporate recognition capabilities, but there are some use cases where they might need to be used for general tasks outside of a conventional workflow. A number of Accusoft customers, for instance, had inquired about simple ways to use some of SmartZone’s features in their existing process automation software without having to spend weeks of development time integrating those capabilities on a larger scale.

Thanks to the versatility of PowerShell, there’s no reason to build such an application from scratch. SmartZone’s zonal recognition technology can easily be incorporated into any .NET environment with just a few snippets of code. PowerShell syntax itself is not very difficult to understand and for a quick start it should be enough to use a Windows Notepad application, but we recommend using your favorite integrated development environment (IDE) for a better experience.

Getting Started

First, you need to download SmartZoneV7.0DotNet-AnyCPU.zip from the Accusoft SmartZone download page and unpack it to any suitable directory. This bundle contains all required binaries to run SmartZone.

Create a Simple.ps1 file inside the unpacked directory and start typing your script:


using namespace System.Drawing
using namespace System.Reflection
using namespace Accusoft.SmartZoneOCRSdk

# Load assemblies.
Add-Type -AssemblyName System.Drawing
$szPath = Resolve-Path ".\bin\netstandard2.0\Accusoft.SmartZoneOCR.Net.dll"
[Assembly]::LoadFrom($szPath)

# Create a SmartZone instance.
$szObj = [SmartZoneOCR]::new()
$szAssetsPath = Resolve-Path ".\bin\assets"
$szObj.OCRDataPath = $szAssetsPath.Path

# Licensing
# $szObj.Licensing.SetSolutionName("Contact Accusoft for getting the license.")
# $szObj.Licensing.SetSolutionKey(+1, 800, 875, 7009)
# $szObj.Licensing.SetOEMLicenseKey("https://www.accusoft.com/company/legal/licensing/");

# Load test image.
$bitmapPath = Resolve-Path ".\demos\images\OCR\MultiLine.bmp"
[Bitmap] $bitmap = [Image]::FromFile($bitmapPath.Path)

# Recognize the image and print the result.
$result = $szObj.Reader.AnalyzeField([Bitmap] $bitmap);
Write-Host $result.Text

# Free the resources.
$bitmap.Dispose();
$szObj.Dispose();


This simple code snippet allows you to use SmartZone together with PowerShell in task automation processes like recognizing screenshots, email attachments, and images downloaded by the web browser. It can also be deployed in other similar cases where the advantages of PowerShell modules and cmdlets can help to achieve results faster than writing an application from scratch.

Another Hackathon Success

Identifying a new way to deploy existing Accusoft solutions is one of the reasons why the hackathon event was first created. This script may not reinvent the wheel, but it will help developers save time and money in a lot of situations, which means fewer missed deadlines and faster time to market for software products. Developing unique approaches to existing problems can be difficult with deadlines and coding demands hanging over a developer’s head, so Accusoft’s hackathons are incredibly important for helping the company stay at the forefront of innovation. 

To learn more about how that innovation can help your team implement powerful new features into your applications, talk to one of our solutions experts today!

Redacting documents is critically important for legal departments and government agencies. By removing sensitive information from a digital file before sharing it publicly, it’s possible to protect private data or classified materials from being exposed. 

In the days before digital documents, redaction involved a simple, if crude, process of covering text with a black marker. Since redactions were done by hand, it was easy for mistakes to be made, which could range from using insufficiently dark ink to leaving portions of text exposed. The development of high-powered photo enhancement has rendered this approach all but useless, as even inexpensive image processing technology can distinguish blacked-out text.

With the transition to digital documents, organizations finally have access to true redaction capabilities. Unfortunately, they still tend to make mistakes when it comes to flattened PDFs that could leave redacted context exposed and vulnerable.

What Is a Flattened PDF?

A modern PDF file consists of multiple layers, each of which can contain separate elements. One layer might feature text, another image, and yet another a fillable form. The flattening process removes all interactive elements from form fields and combines all of the document’s elements into a single layer. 

Organizations frequently used this process to “lock in” form content to prevent anyone from altering the information after a user completes the forms. It also removes elements like dropdown selections within form fields and can burn in other annotations or markups, making them a permanently visible element of the document.

Flattened PDF Redactions

Unfortunately, simply flattening a PDF is usually not sufficient to securely redact a document. That’s because obscured elements are still present in the document; they’re just not visible when the file is viewed and printed. 

Recovering improperly redacted content is actually quite trivial in many cases. Two of the most infamous recent examples include information released during the investigation of political campaign chairman Paul Manafort in 2019 and court documents related to Facebook’s use of personal data in 2017. In both cases, journalists were able to copy redacted text from PDF files and paste it into a text editor to reveal the obscured content.

There are typically two ways that improper redactions occur:

  1. Covering Text with Boxes: This frequent mistake occurs when people try to treat a digital document like a physical piece of paper. They place annotations over the sensitive content, usually in the form of a black box, and then save a flattened version of the PDF thinking that no one will be able to separate the text from the annotation element. As the Manafort and Facebook cases demonstrate, however, getting around these “redactions” is usually quite easy.
  2. Changing the Color of Text: Another common redaction error involves altering the color of the sensitive text to match the document background. Changing the text color to white, for instance, might make it invisible to the human eye, but it does nothing to alter the content itself. The text can be made visible again by using the copy/paste trick described above or by altering the background characteristics in another program. 

The only way to make these methods viable for true redactions would be to actually print the documents with the content hidden and then scan them back into digital form, where OCR could be used to reconstruct a new file. But even in this case, there’s a chance that a powerful OCR engine might be able to pick up the hidden elements.

Using Proper Redaction Prior to Flattening with PrizmDoc Viewer

In order to redact documents securely, applications need to have access to specialized redaction tools that are capable of actually removing content from the document itself before applying redaction indicators. PrizmDoc Viewer’s redaction API can find and extract key text while also providing single or multiple reasons for the removal. 

This not only allows organizations to redact documents quickly, but it also ensures that the redacted information won’t be exposed later because it no longer even exists within the document. More importantly, the outputted document is entirely new, so there is no deleted information to recover. 

While most people are familiar with the distinctive black bars that indicate redacted content, even this leaves behind significant context clues that could provide hints of what was removed. Consider, for instance, a document involving multiple parties where the names of conversation participants have been redacted.

The following information:

PDF Redaction

The length of the redaction, then, would at least indicate when the redaction did not involve one person or the other. There are also many instances involving government documents where the length of the redacted information in classified material might suggest its relevance or importance.

When it comes to GovTech applications that need to remove large portions of information for security reasons, it often helps to perform redaction BEFORE turning a document into a flattened PDF. The PrizmDoc Viewer redaction API can be used to quickly extract text from a document and then redact it as a plain text file

Unlike a static PDF document, plain text accounts for width variations, so all redactions can be replaced with a standardized <Text Redacted> marker that makes it impossible to know the length of the redacted content. The text could then be converted into a PDF after the redaction process is complete.

Take Control of PDFs with PrizmDoc Viewer

As a fully-featured HTML5 viewer, Accusoft’s PrizmDoc Viewer delivers powerful viewing, annotation, and conversion functionality to your web application. It provides a broad range of redaction capabilities that allow legal, financial, and government organizations to keep their sensitive data secure and protect their customers. 

By integrating these complex features into your applications, you can focus your development efforts on building the tools that set your solution apart from the competition while our proven technology powers your customers’ viewing and redaction needs. To learn more about PrizmDoc Viewer’s powerful capabilities, download a free trial and test how it can support and enhance your application.