Technical FAQs

Question

What are the absolute essentials for embedding the PrizmDoc Viewer into my web page/application?

Answer

Viewer API (viewercontrol.js)

The Viewer API is the base building block of the Viewer. We ensure that API changes are backward compatible with point releases (for example, PrizmDoc v13.5 → PrizmDoc v13.6) and will not introduce breaking changes unless critical. With major releases we also endeavor to ensure backward compatibility with previous releases of the Viewer API.

HTML Templates (viewerCustomization.js) and CSS (viewercontrol.css, viewer.css)

The Viewer that is shipped with the product will be maintained and enhanced from release to release. The Viewer HTML and CSS markup will change with each release. Once you have begun to modify your markup, it is recommended that you consider subsequent PrizmDoc releases as sample code, in which you would evaluate product changes and choose to incorporate all or parts of those changes into your customization.

JavaScript files (viewer.js)

The Viewer JavaScript that lies above the Viewer API is unobfuscated and open for customization. While we expect many developer needs will be satisfied through configuration parameters and minor HTML or styling changes, some developers will desire to modify viewer.js for more advanced customization. You should carefully consider your development and ongoing maintenance strategy to ensure that future releases of PrizmDoc are easy to integrate into your customizations. We cannot guarantee backward compatibility of viewer.js in future releases as it is central to the functionality of the Viewer.

For information on integrating PrizmDoc Viewer, see the Getting Started section of the documentation.

For more in depth customization, see the PrizmDoc Customization section of the documentation.

Today’s organizations are inundated with a variety of document and image formats on a regular basis. By integrating comprehensive PDF functionality into their applications, developers can provide the tools to manage those files much more easily. Converting files into PDFs makes them easier to share, modify, and annotate without having to worry about compatibility issues across applications.

Simply converting documents or images into searchable PDF files is easy enough, but in many cases, several files need to be merged into a single document or one large file must be split into multiple documents. Accusoft’s ImageGear SDK gives applications the ability to process PDFs programmatically, allowing users to quickly prepare documents for viewing and collaboration.

How to Merge PDF Files with ImageGear Using C#

ImageGear can merge two multi-page PDF documents into a single document. This is especially useful for organizations that have multiple files associated with the same workflow or account, such as loan applications or medical records. The following steps will walk you through the merge PDF process using ImageGear.NET in C#.

Step 1: Initialize PDF Support

Before getting started, you’ll need to initialize PDF support within ImageGear.NET (if you haven’t done so already during deployment). This initialization will allow your application to load, save, and process PDF files.

After creating a new “Console Application” and adding the required assembly reference and resources, you can use the following code snippet to load and save PDF files.

 

using System.IO;
using ImageGear.Formats;
using ImageGear.Formats.PDF;
using ImageGear.Evaluation;
namespace MyPDFProject
{
    class Program
    {
        public void Initialize()
        {
            // Initialize evaluation license.
            ImGearEvaluationManager.Initialize();
            ImGearEvaluationManager.Mode = ImGearEvaluationMode.Watermark;
            // Initialize common formats.
            ImGearCommonFormats.Initialize();
            // Add support for PDF files.
            ImGearFileFormats.Filters.Insert(0, ImGearPDF.CreatePDFFormat());
            ImGearPDF.Initialize();
        }
        public void Terminate()
        {
            // Dispose of support for PDF files.
            ImGearPDF.Terminate();
        }
        public void LoadAndSave(string fileIn, string fileOut)
        {
            ImGearPDFDocument igPDFDocument = null;
            try
            {
                // Load the PDF document.
                using (FileStream inStream = new FileStream(fileIn, FileMode.Open))
                    igPDFDocument = (ImGearPDFDocument)ImGearFileFormats.LoadDocument(inStream, 0, (int)ImGearPDFPageRange.ALL_PAGES);
                // Save the PDF document to a new file.
                ImGearPDFSaveOptions pdfOptions = new ImGearPDFSaveOptions();
                using (FileStream outStream = new FileStream(fileOut, FileMode.Create))
                    ImGearFileFormats.SaveDocument(igPDFDocument, outStream, 0, ImGearSavingModes.OVERWRITE, ImGearSavingFormats.PDF, pdfOptions);
            }
            finally
            {
                igPDFDocument?.Dispose();
            }
        }
        static void Main(string[] args)
        {
            Program myProgram = new Program();
            myProgram.Initialize();
            myProgram.LoadAndSave(@"C:\PATHTOPDF\FILENAME.pdf", @"C:\PATHTOPDF\NEWNAME.pdf");
            myProgram.Terminate();
        }
    }
}

       

 

Step 2: Set the Merge PDF Parameters

You will need to determine what order the documents will be combined in and set the page numeration for the new document.

Step 3: Merge the PDF Documents

Once you’ve identified the files you want to merge and the order they should go in, you can use the “MergePdfDocuments” command to assemble the new PDF file. Here’s what the code snippet looks like in C#:

 

        // Merges two PDF document into a third PDF document.
        public void Merge(string fileInFirst, string fileInSecond, string fileOut)
        {
            // ImageGear uses zero-based page numbers.
            const int FIRST_PAGE_INDEX = 0;
            ImGearPDFDocument igPDFDocumentFirst = null;
            ImGearPDFDocument igPDFDocumentSecond = null;
            ImGearPDFDocument igPDFDocumentResult = null;
            try
            {
                // Load the source PDF documents.
                using (FileStream inStream = new FileStream(fileInFirst, FileMode.Open))
                    igPDFDocumentFirst = (ImGearPDFDocument)ImGearFileFormats.LoadDocument(inStream, 0, (int)ImGearPDFPageRange.ALL_PAGES);
                using (FileStream inStream = new FileStream(fileInSecond, FileMode.Open))
                    igPDFDocumentSecond = (ImGearPDFDocument)ImGearFileFormats.LoadDocument(inStream, 0, (int)ImGearPDFPageRange.ALL_PAGES);
                // Create the resulting PDF document.
                igPDFDocumentResult = new ImGearPDFDocument();
                // Copy all pages of first document into resulting PDF document.
                for (int pageIndex = FIRST_PAGE_INDEX; pageIndex < igPDFDocumentFirst.Pages.Count; pageIndex++)
                    igPDFDocumentResult.Pages.Add(igPDFDocumentFirst.Pages[pageIndex].Clone());
                // Copy all pages of second document into resulting PDF document.
                for (int pageIndex = FIRST_PAGE_INDEX; pageIndex < igPDFDocumentSecond.Pages.Count; pageIndex++)
                    igPDFDocumentResult.Pages.Add(igPDFDocumentSecond.Pages[pageIndex].Clone());
                // Save the resulting PDF document to a new file.
                ImGearPDFSaveOptions pdfOptions = new ImGearPDFSaveOptions();
                using (FileStream outStream = new FileStream(fileOut, FileMode.Create))
                    ImGearFileFormats.SaveDocument(igPDFDocumentResult, outStream, 0, ImGearSavingModes.OVERWRITE, ImGearSavingFormats.PDF, pdfOptions);
            }
            finally
            {
                igPDFDocumentFirst?.Dispose();
                igPDFDocumentSecond?.Dispose();
                igPDFDocumentResult?.Dispose();
            }
        }
        static void Main(string[] args)
        {
            Program myProgram = new Program();
            myProgram.Initialize();
            myProgram.Merge(@"C:\PATHTOPDF\FIRSTFILENAME.pdf", @"C:\PATHTOPDF\SECONDFILENAME.pdf", @"C:\PATHTOPDF\NEWNAME.pdf");
            myProgram.Terminate();
        }

 

After merging your files into a new document, you can begin working with the resulting PDF using ImageGear’s other PDF features:

How to Split PDF Files with ImageGear Using C#

While the merge PDF command is used to combine multiple documents into a new, single PDF file, the split PDF command saves pages from an existing document as a separate document. A three-page PDF file, for instance, can be broken into three, single-page PDF documents.

Once you’ve initialized PDF support for ImageGear.NET, you can split a PDF document by following a few simple steps:

Step 1: Read the PDF into a System.IO.Stream Object

This allows ImageGear to read the stream using ImGearFileFormats.LoadDocument(FILE NAME) command.

Step 2: Determine PDF Page Count

The ImGearPDFDocument.Pages property provides access to the document’s page array, which can then be used to assemble a new document.

Step 3: Create a New PDF Document

The ImGearPDFDocument object can be used to create an empty PDF document that will serve as the destination file for the split pages.

Step 4: Insert Pages into the New Document

The InsertPages command takes specific pages from the source document (the PDF you’re splitting), and inserts them into the destination document. After the pages are inserted, you can save the new PDF to disk or memory. Keep in mind that the original document will still contain all pages, so splitting it into two documents will require you to create two new documents.

Here is a what splitting a single PDF document into several single-page PDF documents looks like in C#:

 

public void Split(string fileIn, string directoryOut)
        {
            // ImageGear uses zero-based page numbers.
            const int FIRST_PAGE = 0;
            // Ensure output directory exists.
            if (!System.IO.Directory.Exists(directoryOut))
                Directory.CreateDirectory(directoryOut);
            // Load the source PDF document.
            using (FileStream inStream = new FileStream(fileIn, FileMode.Open))
            {
                using (ImGearPDFDocument igPDFDocument = ImGearFileFormats.LoadDocument(inStream, FIRST_PAGE, (int)ImGearPDFPageRange.ALL_PAGES) as ImGearPDFDocument)
                {
                    // Write each page in source PDF document to a separate PDF file.
                    for (int pageIndex = FIRST_PAGE; pageIndex < igPDFDocument.Pages.Count; pageIndex++)
                    {
                        // Construct the output filepath.
                        string outputFileName = string.Format("{0}_{1}.pdf", Path.GetFileNameWithoutExtension(fileIn), pageIndex + 1);
                        string outputPath = System.IO.Path.Combine(directoryOut, outputFileName);
                        // Create a new empty PDF document.
                        using (ImGearPDFDocument igPDFDocumentResult = new ImGearPDFDocument())
                        {
                            // Insert page into new PDF document.
                            igPDFDocumentResult.InsertPages((int)ImGearPDFPageNumber.BEFORE_FIRST_PAGE, igPDFDocument, pageIndex, 1, ImGearPDFInsertFlags.DEFAULT);
                            // Save new PDF document to file.
                            igPDFDocumentResult.Save(outputPath, ImGearSavingFormats.PDF, FIRST_PAGE, FIRST_PAGE, 1, ImGearSavingModes.OVERWRITE);
                        }
                    }
                }
            }
        }
        static void Main(string[] args)
        {
            Program myProgram = new Program();
            myProgram.Initialize();
            myProgram.Split(@"C:\PATHTOPDF\FILENAME.pdf", @"C:\PATHTOPDF\OUTPUTDIRECTORY");
            myProgram.Terminate();
        }

 

Enhance Your PDF Capabilities with ImageGear

Accusoft’s ImageGear SDK provides a broad range of document and image processing functions beyond the ability to split and merge PDFs. Whether you need powerful file conversion capabilities, multi-language OCR support, or image cleanup, correction, and transformation functions, ImageGear integrations can enhance your application’s performance and versatility. 

Learn more about the ImageGear collection of SDKs and see how they can help you shorten your development cycle and get your innovative products to market faster.

Question

When printing non-standard size raster images with PrizmDoc they can sometimes become cutoff if too tall or wide. How can I correctly print a non-standard size raster image with PrizmDoc?

Answer

(This explanation is done for a tall portrait image, but can be altered to work for a wide landscape image by flipping the width and height.)

To do this, you have to add a custom paper size to viewerCustomization.js and specify a smaller width so that there is enough room to fit the height of the image on a single page.

To find the correct width value so that the image will fit on a single page, you will need to do some math. In this example, we’ll use an image that is 1305×2823. In this case, the width is 46.2% of the height. If you want to print onto 8.5×11 inch paper, then the width you want to set for your new custom paper size is 11*0.462, which comes out to 5.082.

So now that you have the width, you need to create the new custom paper size. In viewerCustomization.js in the templates section, find the "print" template and add the following code where the other printing paper sizes are located.

/*custom */
.portrait .custom.page { width: 5.082in; height: 11in; margin: 0 auto !important; }
.portrait .custom.pageIE { width: 9.5in; height: 9.5in; margin: 0 auto !important; }
.portrait .custom.pageSafari { width: 8.9in; height: 8.9in; margin: 0 auto !important; }
.portrait .custom.nomargins { width: 11in !important; height: 11in !important; }

/* even without margins, Safari enforces the printer's non-printable area */
.portrait .custom.nomargins.pageSafari { width: 9.32in !important; height: 9.32in !important; }

.landscape .custom.page { height: 5.082in; width: 11in; margin: 0 auto !important; }
.landscape .custom.pageIE { height: 9.05in; width: 9.05in; margin: 0 auto !important; }
.landscape .custom.pageSafari { height: 8.4in; width: 8.4in; margin: 0 auto !important; }
.landscape .custom.nomargins { height: 11in !important; width: 11in !important; }
.landscape .custom.nomargins.pageSafari { height: 9.32in !important; width: 9.32in !important; }
/*custom end*/

As you can see, the width for .portrait .custom.page was set to 5.082in, and the height set to 11in. This will scale the 1305×2823 image to fit on a single 8.5×11 page when printing. By flipping the values and setting them in .landscape you would be able to print a 2823×1305 image on a single landscape page. (Just to note, I only edited the values for .custom.page for portrait and landscape. The others would most likely need to be changed.)

Next you need to add an option for your new paper size to the "paperSize" selection tag in the "printOverlay" section of templates in viewerCustomization.js. Your select tag should end up looking something like this:

<select data-pcc-select="paperSize" class="pcc-print-select">
    <!-- US and International-->
    <option value="letter"><%= paperSizes.letter %></option>
    <option value="legal"><%= paperSizes.legal %></option>
    <option value="tabloid"><%= paperSizes.tabloid %></option>
    <option value="foolscap"><%= paperSizes.foolscap %></option>
    <!-- A formats-->
    <option value="a3"><%= paperSizes.a3 %></option>
    <option value="a4"><%= paperSizes.a4 %></option>
    <option value="a5"><%= paperSizes.a5 %></option>
    <!-- Architectural-->
    <option value="a6"><%= paperSizes.a6 %></option>
    <option value="a"><%= paperSizes.a %></option>
    <option value="b"><%= paperSizes.b %></option>
    <option value="c"><%= paperSizes.c %></option>
    <option value="d"><%= paperSizes.d %></option>
    <option value="e"><%= paperSizes.e %></option>
    <option value="e1"><%= paperSizes.e1 %></option>
        
    <option value="custom">Custom</option>
</select>

The new print option should now appear in the PrizmDoc print settings when selecting a paper size, and it should print the image on a single page.

One thing to note is that you will have to do this for each differently sized image. If you are unsure of the size of uploaded documents, this solution will most likely not be usable.

.net document viewer

Adding document viewing features to an application can be a challenge. Although there are many open source options available, finding a suitable ASP.NET document viewer or .NET image viewer that provides the right level of flexibility and functionality often requires a more specialized solution. Fortunately, .NET developers have good options when the time comes to integrate document viewing into their software, which helps them to focus on other application features.

The API Document Solution

Rather than building a dedicated viewer within their .NET application, many developers instead turn to an HTML5 viewer integration that uses REST APIs for their document needs. Since these viewers work within the web browser and can support any programming language, they provide the right balance of versatility and performance for most software applications. An HTML5 document viewer ensures a consistent viewing experience across multiple software platforms and browsers used within an enterprise environment.

Of course, if all an application needed to do was view files, it could simply use one of many open-source solutions. The problem is that these viewers typically only view one type of file, which means that the application also needs the ability to convert files into different formats. Depending upon the library in question, this could quickly escalate into a code-heavy solution that bogs down application performance and introduces multiple security vulnerabilities. If poor conversion tools are put in place, there’s also a strong likelihood that documents will not render accurately.

An HTML5 viewer with the right APIs can easily overcome these document management challenges for a .NET application. Conversion, annotation, comparison, and redaction features can all be integrated as part of a comprehensive viewing framework that doesn’t require developers to build anything from scratch or rely upon intrusive plugins that create risky dependencies.

How Accusoft APIs Enhance Your .NET Application

Accusoft’s PrizmDoc Viewer was designed to provide a broad range of document processing capabilities in addition to its core HTML5 viewing features. Once integrated into a .NET application, it allows developers to deploy REST API calls to convert files into new formats, split and merge documents, create page thumbnails, markup documents, and perform high-volume text searches. As an HTML5 viewer, PrizmDoc Viewer can deliver all of that functionality right within the browser rather than resorting to external applications.

The primary advantage of REST APIs is that they can be used from any programming language, so they don’t have to be custom-built to serve as an ASP.NET document viewer. That versatility does come with a tradeoff, however. Processes like uploading files, converting them, and then downloading outputs all require a series of HTTP requests. While this isn’t a particularly difficult process, it is slightly more resource-intensive than a solution built using the same programming language as the application. 

That’s why we developed a .NET SDK library that wraps around the server-related functions of PrizmDoc Viewer. Available for both .NET Core and .NET Framework, this SDK library wraps around the server’s REST APIs to make it easier to utilize server functionality in .NET applications.

For .NET developers looking for a better way to view and process documents, the PrizmDoc .NET SDK can help them access conversion, redaction, and annotation features without compromising the performance of their .NET applications.

Getting Started with PrizmDoc .NET SDK

In order to implement the .NET wrapper, developers just need to follow a few simple steps. 

1. Gain Access to a PrizmDoc Server Deployment

There are two ways to access PrizmDoc Server, which will allow you to carry out a variety of document processing functions. You can host a server on-premises as part of a PrizmDoc Viewer integration or sign up for a PrizmDoc Cloud account to use Accusoft’s cloud-hosted deployment.

2. Add the PrizmDoc Server .NET SDK Package

Next, download the free, open source .NET SDK library from NuGet or GitHub and add it to your application project.

dotnet add package Accusoft.PrizmDocServerSDK

 

3. Create a new PrizmDocServerClient

Once the .NET wrapper is in place, it’s time to construct a new PrizmDocServerClient and connect it to the server.

For a self-hosted PrizmDoc Server that’s part of a PrizmDoc Viewer deployment, the base URL is all that’s needed:

var prizmDocServer = new PrizmDocServerClient("http://localhost:18681");

 

If the you’re using PrizmDoc Cloud, you’ll need to provide the base URL along with your API key:  

var prizmDocServer = new PrizmDocServerClient("https://api.accusoft.com", "YOUR_API_KEY");

 

4. Begin Document Processing

Now that everything is in place, you can start processing and viewing documents within your .NET application. Our How To Guides provide some examples of common use cases, and you can also turn to the API Reference for additional guidance and information.

Get the Document Viewing Features Your .NET Application Needs

Accusoft’s PrizmDoc Viewer delivers the versatile HTML5 viewing capabilities that can set your .NET application apart from the competition. Thanks to the PrizmDoc Server .NET SDK wrapper, you can leverage the power of our REST APIs without needing to build out a customized viewing solution from the ground up.

Find out how easily you can manage your document needs with PrizmDoc Viewer’s browser-based functionality today. Sign up for a free trial to test our HTML5-powered viewer in your .NET environment.

Having the right file conversion tools in place can make or break an application. Developers frequently face the challenge of managing multiple file types within a consolidated workflow. Without effective conversion tools, users are forced to rely on external applications that compromise both efficiency and security.

Out of all the file formats developers must account for, PDFs remain among the most important. The ability to convert a wide variety of document and image file types into PDF format can provide an application with unmatched versatility. In fact, PDF conversion support is one of the keys to unlocking better workflow performance, security, and collaboration.

5 Reasons to Convert Files to PDF


1. PDF Format is Consistent

Sharing documents and images across different devices and operating systems can sometimes create problems if the recipient lacks the up-to-date software necessary to view the file properly. This is a particular challenge with documents created using Microsoft Word since the formatting could look quite different across different versions of the program. Since PDF files are designed to look the same no matter how they’re being viewed, the format is ideal for sharing. Both documents and images can display equally well as PDFs, so converting files into this format is a quick and easy way to make them accessible for viewing.

2. PDF Files Are Easily Compressed

Sharing large image files can be a challenge for many organizations. High-resolution JPEG or TIFF files are often too large to share over email or web-based applications. Converting them to compressed PDFs is a quick way to reduce file size for easier sharing while still retaining a copy of the original file. Since the compressed version is in PDF format, there is less chance of version confusion when someone needs to access the original source image.

3. PDFs Are Widely Supported

Although PDFs once required specialized viewing software, thanks to JavaScript-based libraries like PDF.js, they can now be viewed by a conventional web browser. For all intents and purposes, this has made PDF a universal file format that can be viewed on any device. Converting a file into PDF ensures that it will be accessible to anyone who is granted access to it, regardless of the device or operating system they’re using.

4. PDFs Offer Security Protections

For many organizations, protecting privacy and confidential information is incredibly important. Converting document and image files into PDF format allows them to take advantage of the standard’s security features. Passwords can be set to authorize viewing and editing access to a file, which not only helps to ensure privacy but also limits who can make changes to a file so version control is easier to maintain. Files can also be converted into PDF/A format for secure archival purposes.

5. PDFs Support Annotation Markups

Most PDF viewing solutions support some form of annotation markups, which allows multiple contributors to make notes and comments on a file. Converting documents or images into a PDF facilitates this collaboration while safely preserving the original version of the file for future reference. Since PDF viewers provide a variety of annotation tools, they offer a great deal of flexibility when it comes to marking up images and documents without having to depend upon specialized software. Image and document files with additional annotation layers can also be converted into flattened PDFs for easier viewing.

Converting Files to PDF Using ImageGear

Accusoft’s ImageGear provides an extensive array of file conversion tools that allow developers to easily save multiple document and image file types into PDF format. With these conversion capabilities built into the back end of their applications, developers can help customers streamline their file management.

Converting Microsoft Documents to PDF

ImageGear supports the conversion of multiple Microsoft Office documents, including Word (DOCX/DOC), Excel (XLSX/XLS), and PowerPoint (PPTX/PPT). The conversion engine supports all text elements, raster images, and graphic shapes for Microsoft Office Open XML and Microsoft Office 97-2003 formats. It can convert the entire document into a PDF as well as any designated page or page ranges. The following examples show how this can be done using C#.

Converting Microsoft Word to PDF

To convert a Microsoft Word document in its entirety, the first step involves loading the ImageGear filters to create the input and output instances: 

ImGearFileFormats.Filters.Add(ImGearOffice.CreateWordFormat());
ImGearFileFormats.Filters.Add(ImGearPDF.CreatePDFFormat());

For the next step, the PDF library needs to be initialized:

ImGearPDF.Initialize();

The ImGearFileFormats.LoadDocument method is then used to read all pages of the file:

ImGearDocument igDocument;
using (FileStream fileStream = new FileStream(inputFileName, FileMode.Open,
       FileAccess.Read, FileShare.Read))
{
   igDocument = ImGearFileFormats.LoadDocument(fileStream);
}
Finally, the ImGearFileFormats.SaveDocument method is used to save the output PDF: 
using (FileStream fileStream = new FileStream(outputFileName, FileMode.Create,
       FileAccess.ReadWrite))
{
   ImGearFileFormats.SaveDocument(igDocument, fileStream, 0,
       ImGearSavingModes.OVERWRITE, ImGearSavingFormats.PDF, null);
}

Converting Microsoft Excel and PowerPoint to PDF

The process for converting Excel and PowerPoint files follows the same basic format as converting Word files. First, initialize the input, then modify the sample code from above for the appropriate formats.

To initialize Excel:

ImGearFileFormats.Filters.Add(ImGearOffice.CreateExcelFormat());

To modify sample’s open file dialog for XLSX/XLS extensions:

ofd.Filter = @"DOCX files (*.docx)|*.docx|XLSX files 
(*.xlsx)|*.xlsx|XLS files (*.xls)|*.xls";

To initialize PowerPoint:


ImGearFileFormats.Filters.Add(ImGearOffice.CreatePowerPointFormat());

To modify sample’s open file dialog for PPTX/PPT extensions:

ofd.Filter = @"DOCX files (*.docx)|*.docx|PPTX files 
(*.pptx)|*.pptx|PPT files (*.ppt)|*.ppt";

Converting an Image File to PDF

ImageGear PDF supports the conversion of multiple image types into PDF format just as easily as it converts documents, but the process looks a bit different in code. After initializing PDF support for ImageGear.NET, the following C# example can be used to load an image file and then save it as a PDF page. The conversion process can be used for any file format that ImageGear supports.

using System;
using System.IO;

using ImageGear.Core;
using ImageGear.Formats;
using ImageGear.Formats.PDF;
using ImageGear.Evaluation;

public void SaveImageAsPDF(string inputFilePathName, string outputFilePathName)
       {
           try
           {
               const int FIRST_PAGE = 0;

               // Initialize evaluation license.
               ImGearEvaluationManager.Initialize();
               ImGearEvaluationManager.Mode = ImGearEvaluationMode.Watermark;

               // Initialize common formats.
               ImageGear.Formats.ImGearCommonFormats.Initialize();

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

               // Load required page from a file.
               ImGearPage page = null;
               using (Stream stream = new FileStream(inputFilePathName, FileMode.Open, FileAccess.Read))
                   page = ImGearFileFormats.LoadPage(stream, FIRST_PAGE);

               // Save page as PDF document to a file.
               using (Stream stream = new FileStream(outputFilePathName, FileMode.Create, FileAccess.Write))
                   ImGearFileFormats.SavePage(page, stream, FIRST_PAGE, ImGearSavingModes.OVERWRITE, ImGearSavingFormats.PDF);
           }
           catch (Exception exp)
           {
               // Write error to Console window.
               Console.WriteLine(exp.Message);
           }
           finally
           {
               // Call PDF engine terminating in any case.
               ImGearPDF.Terminate();
           }
       }

 

Add Conversion Flexibility to Your Application with ImageGear

Accusoft’s ImageGear provides applications with comprehensive conversion, annotation, and viewing support for PDF files. As part of the broader ImageGear collection, it also delivers powerful image processing capabilities and support for multiple document and image file types. These features can help turn any application into a robust document management platform capable of streaming workflows and empowering collaboration.

If you’re ready to see how the SDK will function as part of your development environment, start your free trial and get straight to the code.

Here at Accusoft, we’re always looking for new ways of connecting people with progress to improve productivity and drive innovation. It’s why we put so much work into our standards-based APIs and SDKs. We understand that developers need mature integrations that are ready to enhance their applications from day one and will be supported by extensive, accurate documentation. From the onset of 2020, we had a strategy in place to help us focus on making it easier for our customers to solve their business problems.

And then, well, 2020 happened…

As this challenging year finally comes to a close, we wanted to take a look back at how we adapted to stay focused on our enduring mission to deliver better products and services to our customers.

2020 Customer Advisory Board Meetings

Since most of our products are delivered through APIs and SDKs, we often encounter situations where our customers and partners independently purchase, download, and extend applications with minimal interaction. Historically, this made it difficult to gain insight into how our clients utilized many of our solutions and what features they would like to see from them in the future.

That’s why we hosted our first Board of Connectors (BoC) meeting in 2019 to bring customers and product managers together in an ongoing dialogue about business needs and product strategy. These meetings also had the benefit of allowing our customers to build relationships with our internal teams, provide feedback on product features, share their business challenges, and discuss key development trends impacting their respective industries.

We had the good fortune to hold our first BoC meeting in-person before the COVID-19 pandemic forced us to adopt rigorous social distance and work-from-home protocols for the safety of our employees and customers. Our second meeting took place in virtual format later in the year, which allowed us to learn first-hand how our customers were dealing with pandemic pressures and how we could adjust our product strategies to meet their rapidly shifting needs.

An Eventful 2020 for PrizmDoc Viewer

One of the principal beneficiaries of these meetings was our popular PrizmDoc Viewer solution. As a best-in-class HTML5 viewer, PrizmDoc Viewer was already a powerful and versatile viewing integration capable of enhancing a variety of applications. But if there’s one thing we’ve learned over the years, it’s that there’s always room for improvement.

That’s why we made it a point of emphasis to implement the top five requests we heard at the first BoC meeting of 2020. Despite all the disruption of COVID-19, we’re incredibly pleased that we were able to deliver on every one of these requests. We also rolled out a host of new product features and continued to optimize PrizmDoc Viewer for improved performance.

Here’s a quick rundown of the five big PrizmDoc Viewer upgrades of 2020:

v.13.11: February 2020 

For the first release of the year, we focused on improving performance when viewing large raster images. We also wanted to make PrizmDoc Viewer easier to install and upgrade.

What we did:

  • Improved the PrizmDoc Viewer Raster Conversion Service to significantly reduce memory consumption and reduce the time it takes to generate raster tiles when viewing large image files.
  • In addition to our traditional installers for Windows and Linux, we released new PrizmDoc Server and PrizmDoc Application Services (PAS) Docker images for production deployments, making the setting up of the PrizmDoc Viewer backend dramatically easier.
  • Released a new .NET SDK for PrizmDoc Server – for .NET developers doing backend document processing with PrizmDoc Server this wrapper around the PrizmDoc Server REST APIs makes it easy to use PrizmDoc Server functionality in .NET.
  • Upgraded the PrizmDoc Server installer to allow for in-place upgrades so users no longer need to uninstall the previous version before installing the newest version.

v.13.12: April 2020 

For the second release of the year, we expanded our use of Docker technology to make PrizmDoc Viewer easier to evaluate. We also worked to improve the performance and stability of PrizmDoc Server.

What we did:

  • Released a new evaluation Docker image that provides a demo web application to explore the viewer and its features, and start a complete PrizmDoc Viewer backend to begin using for local development.
  • Updated online help with a new look and feel for easier navigation. Added a new getting started topic for streamlined evaluation, and initial integration topic for an easy transition after evaluation. 
  • Improved performance and stability of PrizmDoc Server when viewing complex PDF documents.

v.13.13: June 2020 

This release saw the rollout of a new redaction feature along with myriad performance improvements.

What we did:

  • Provided support for multiple redaction reasons via our client API so users can apply more than one reason, selected from a customizable list, to any redaction reason. Reasons appear on top of the black box of redacted content and can be burned into a downloadable PDF along with the rest of the redacted content. Developers can also import a pre-built set of redaction reasons from an existing JSON file for streamlined end-user application.
  • Improved conversion times and memory consumption when viewing multi-page DWF documents.
  • Improved performance when retrieving revision data and scrolling through results when comparing two versions of a Word document.

v.13.14: September 2020

The fall release saw new support for viewing email attachments, more redaction features, and continued improvements to the upgrade process.

What we did:

  • Added support for opening email attachments in the same viewer window where the original email is being viewed. Improved the client UI to show email attachments in a compact dropdown menu.
  • Added server-side support for multiple redaction reasons using the Redaction Creators API.
  • Released the ability to draft redactions without obscuring the content, allowing users to produce PDF documents with transparent redactions that display the document content underneath the redaction rectangles.
  • Added the ability to retain configuration setting when upgrading PrizmDoc Server and PAS.

v.13.1: December 2020

The final update of 2020 focused primarily on reducing resource strain, but also saw the release of new sample code and added new Java Virtual Machine (JVM) controls.

What we did:

  • Optimized log entries for the PrizmDoc PDF processing service to dramatically reduce log file size and storage needs.
  • Enhanced PrizmDoc service health detection to automatically return to healthy status as soon as a failed backend service returns to normal operation, eliminating a potential need to restart PrizmDoc Server.
  • Released two new Angular samples on GitHub: a .NET backend sample and a Java backend sample.
  • Added new parameters in central configuration that provide controls for JVM settings when starting PrizmDoc Server Java-based services.

What’s Next for 2021?

Following our virtual BoC meeting in Q3, our product teams have been hard at work developing new features for the upcoming year that will continue to meet the diverse use case needs of our clients’ applications. We want to build on our successes in 2020 when it comes to engaging our customers and using their direct feedback to make beneficial and lasting improvements to our family of SDK and API solutions.

If you’re currently using our products and would like to participate in one of our upcoming BoC meetings for 2021 to submit feedback or learn about future releases, contact us today! We’re looking forward to working with you in the new year!

JavaScript PDF annotation

Ever since Mozilla’s development of the open-source PDF.js library in 2011, many developers have been quick to utilize the JavaScript-based toolkit to quickly integrate PDF viewing capabilities into their applications. Given the severe limitations and security concerns associated with external reader plug-ins, it’s easy to see why the open source library was so appealing. 

Unfortunately, many development teams that lacked experience with document management and image rendering quickly discovered that PDF.js lacked many of the core features they expected from a PDF reader. Front and center among these capabilities was JavaScript PDF annotation, which is essential for almost any application that manages documents. That’s why Accusoft set out to build a lightweight SDK upon the PDF.js library that, among other things, added a vital annotation layer to the viewer.

Making PDF.js Draw Annotations

The PDF.js library consists of three different layers that all work together to render and display files. A core layer interprets the binary data in a file before passing it on to a display layer that renders the PDF itself into a <canvas> element. The viewer layer provides the main interface that allows people to view and interact with the file. Out of the box, however, the viewing layer doesn’t provide much in the way of functionality. Interaction is fairly limited without substantial extra development work to add capabilities like mobile screen responsiveness or high fidelity zoom. The core and display layers also don’t display the full PDF specification and struggle with lengthy documents and image-intensive files.

When our team started developing Accusoft PDF Viewer, the very first step was to shore up those support and rendering deficiencies. After making a number of key optimizations to improve rendering speed and fidelity, search speed, and mobile responsiveness, adding a PDF.js annotation layer was among the first priorities. This process was made a bit easier since Accusoft PDF Viewer uses a custom-built viewing layer rather than the default PDF.js viewing layer. In addition to providing a number of performance benefits, building a new viewer gave the team a great deal of control over how users can view and interact with documents.

One of the primary goals of developing this lightweight PDF SDK was that functionality could not come at the expense of performance. The new layer for JavaScript PDF annotations sits atop the PDF.js library, which preserves rendering speed and fidelity while also making it easy for developers to access and utilize annotation features. Since the rendered document is easily accessible, any annotations associated with it can still be retrieved and loaded within the viewing layer.

Anatomy of JavaScript PDF Annotations in Accusoft PDF Viewer

The Professional version of Accusoft PDF Viewer supports multiple different types of annotations, all of which can be incorporated into the customized user interface. This allows developers to quickly integrate PDF viewing capabilities into web applications, enable annotation controls, and then retrieve and load markups whenever the file is retrieved for viewing. 

In order to retrieve JavaScript PDF annotations, developers can use the getAnnotations function. This effectively exports a copy of the annotations made in one viewer so they can be loaded into a different viewer. It’s important to remember that the returned objects are a copy of the annotations, so any changes made to them will not affect the annotations in the original viewer. Furthermore, any changes made to the annotations in the original viewer will not be reflected in the exported versions. To update them, the getAnnotations function would need to be used again.

JavaScript PDF Annotation Tools in Accusoft PDF Viewer Professional

Accusoft PDF Viewer Professional offers several annotation tools. Since the SDK allows developers to customize the viewing interface to fit their application’s needs, one or all of these markup types may be removed from the toolbar if necessary. This may be desirable for situations where a document should only be available for viewing.

  • Ellipse/Circle: A classic oval shape, the ellipse tool can be adjusted in a number of ways to expand its functionality. Developers can set qualities such as opacity, fill color, and border thickness as needed.
  • Rectangle/Square: Typically used to draw boxes around text, the rectangle tool can be customized to meet annotation needs by altering the border thickness and color, adjusting opacity, or designating fill color.
  • Line: Line markups are one of the more versatile annotation types. Accusoft PDF Viewer allows users to not only change the color and thickness of the line, but also to determine whether the line features a triangle end head, which allows it to serve as an arrow.
  • Freehand Signature: Particularly useful for many document management applications, the freehand tool allows users to electronically sign documents or make freehand comments on a PDF. The JavaScript PDF annotation layer tracks the drawing path of the markup as a string value.
  • Free Hand Annotation: The freehand annotation tool allows users to freely draw on a document using their mouse, finger, or stylus. It’s often used to provide quick feedback on a document, especially on mobile devices.
  • Text Highlight: Much like a highlighter pen back in school, the text highlight tool can be used to select and apply a background color to text. When reviewing documents, it can be deployed to highlight sections of content that require closer attention in the future.

Unlock the PDF Potential of Your Application

The customizable PDF features of Accusoft PDF Viewer Professional allow developers to easily integrate powerful annotation capabilities into their application with just a few lines of code. Since the viewer’s JavaScript PDF annotations are made entirely within the web application, there’s no need to configure complicated servers that could impact performance or create additional points of failure. Developers can adjust the viewer interface or even remove the Accusoft branding to create a seamless viewing experience that gives them total control over how their files are viewed and potentially marked up using annotation tools.

Accusoft PDF Viewer was designed with responsive support for mobile displays right out of the box, making it an ideal solution for web applications accessed from multiple devices. It also incorporates three decades of Acusoft’s experience with image processing and document rendering to deliver a viewing experience that’s head and shoulders above open-source PDF.js solutions. Find out how easily your application can add high-performance PDF capabilities by downloading a trial of Accusoft PDF Viewer today. 

Today’s applications need tremendous versatility when it comes to document management. Developers are expected to deliver tools that can handle multiple file types and have the ability to share them securely with internal users and people outside the organization. As more companies transition to remote-first work environments, online (and secure) collaboration tools are becoming a must-have feature. One of the major challenges facing developers is how to adapt existing document technologies and practices to an increasingly interconnected environment without creating additional risks.

Rendering and Conversion Challenges of Microsoft Office

Microsoft Office (MSO) files have long presented problems for organizations looking for greater flexibility when it comes to viewing and marking up documents. This stems in part from the widespread reliance on the Office software itself, which held a staggering 87.5 percent share of the productivity software market according to a 2019 Gartner estimate. Companies of all sizes across multiple industries rely on programs like Word, Excel, and PowerPoint, but there are many instances where they would like to be able to share those documents without also surrendering control of the source files.

The challenge here is twofold. On the one hand, if an organization shares an MSO file with a client or vendor, there’s no guarantee that the recipient will be able to view it properly. They may not have access to Office, in which case they can’t open the file at all, or they may be using an outdated version of the software. While they may still be able to open and view the file, it may not display as originally intended if it uses features not included in previous editions of Office.

On the other hand, however, sharing files outside a secure application environment always creates additional risk. Microsoft Office documents are notoriously attractive targets for hackers seeking to embed malicious code into files, and older, unpatched versions of the software contain numerous known vulnerabilities. Sharing MSO files with an outside party could quickly result in the file being exposed to a compromised machine or network. There’s also a question of version control and privacy, as a downloaded file could easily be copied, edited, or even distributed without authorization.

Unfortunately, it has proved quite difficult to natively render MSO documents in another application. Anyone who has had the misfortune of trying to view or edit a DOCX file in Google Docs will understand the challenges involved. While it’s certainly possible to render MSO files in a different application, the end result is often a little off the mark. Fonts may be rendered incorrectly, formatting could be slightly (or drastically) off, and entire document elements (such as tables, text fields, or images) could be lost if the application doesn’t know how to render them properly.

Rendering MSO Files Natively with PrizmDoc Viewer

As a fully-featured HTML5 viewing integration, Accusoft’s PrizmDoc Viewer can be deployed as an MSO file viewer that renders them like any other document type. However, this doesn’t provide a true native viewing experience, which many businesses require for various compliance reasons. Fortunately, the PrizmDoc Server’s Content Conversion Service (CCS) allows applications to natively render MSO documents with a simple API call.

The MSO rendering feature allows PrizmDoc to communicate directly with an installed version of Microsoft Office, which ensures that every element of the file is rendered accurately within the HTML5 viewer. For example, a DOCX file opened in Microsoft Word should look identical to the same document rendered within an application by PrizmDoc Viewer. Once the document is accurately rendered, it can be shared with other users inside or outside an organization. This allows people to view and even markup MSO files without the original source file ever having to leave the secure application environment. It’s an ideal solution for reducing security risks and eliminating the possibility of version confusion.

Converting Additional MSO File Elements

In many instances, organizations need to share MSO files that have already been marked up or commented upon. This could include Word documents with multiple tracked changes or PowerPoint slides with extensive speaker notes. Those additional markups could be important elements that need to be shared or reviewed, so it’s critical to include them during the conversion and rendering process.

Using the server’s CCS, PrizmDoc Viewer can convert Word documents with accepted or rejected markup changes when converting the file into a different format (such as converting an MSO file to PDF) or rendering it for viewing in the application itself. The same capabilities extend to PowerPoint presentations with speaker notes. When converting these MSO files, the outputted version can consist of slides only or include the speaker notes along with them.

These conversion and rendering capabilities provide developers tremendous flexibility when they’re integrating viewing features into their applications. They can easily deploy them to help their customers collaborate and share MSO files without having to remove them from a secure environment. It’s also a winning feature for end users, who don’t need to worry about downloading files or having access to the latest version of Microsoft Office.

Improve Your Document Capabilities with PrizmDoc Viewer

With its extensive file conversion, redaction, and annotation capabilities, Accusoft’s PrizmDoc Viewer is an essential integration for any document management platform that requires an MSO file viewer. It provides support for dozens of file types to give applications the flexibility needed to meet the demands of today’s complex workflows and improve efficiency. As an HTML5 viewer, it can be integrated into any web-based solution with minimal development effort, which frees up valuable resources developers need to focus on the innovative features that will help set their applications apart in a competitive market.

To learn more about PrizmDoc Viewer’s robust feature set, have a look at our detailed fact sheet. If you’re ready to see what our HTML5 viewer will look like within your application environment, download a free trial and start integrating features right away.

JS PDF viewer Accusoft

Document viewing capabilities are no longer a specialized feature that require dedicated applications. Thanks to powerful software integrations, developers can now build PDF viewing into their solutions to create a better user experience and streamline workflows. The growing popularity of mobile devices, however, has posed a few challenges to development teams accustomed to building an exclusively desktop experience, especially when it comes to JavaScript PDF viewers. That’s why one of Accusoft’s key development goals has focused on making a JS PDF viewer responsive to mobile screens.

The Increasingly Mobile Internet

Since 2017, mobile devices have accounted for about half of global internet traffic. This trend has been fuelled primarily by a combination of improved cellular network coverage and the ever-increasing processing capabilities of the average mobile device. It’s hardly a surprise, considering that the latest smartphones are often the most powerful computing device people own. Even for consumers who own desktop or laptops as well, mobile devices make it easy to access internet services on the go, allowing them to manage finances, collaborate on work tasks, or utilize eLearning resources (or watch cat videos).

Today’s customers expect organizations to provide applications that deliver a consistent experience across all devices, regardless of screen size. The era of designing software exclusively for desktop computers and treating mobile support as an afterthought is long gone. If an application’s mobile experience doesn’t at least match that of the competition, customers will quickly make a change.

Viewing Challenges on Mobile Devices

Mobile devices can present a few challenges for application developers, especially when it comes to viewing documents like PDFs. While there are many PDF reader apps available for mobile platforms, they typically require users to download a file to local storage or to a cloud service in order to open a document. In addition to being inconvenient, this often leads to some presentation problems because the reader may not render the PDF exactly as the creator intended, especially if it’s not linearized.

Developers could, of course, rely upon the mobile browser to display documents, but this also introduces problems. As with external reader apps, the browser viewer may not render the document as intended, which creates an uneven user experience across multiple platforms. More importantly, the browser’s interface may lack key controls that enhance the viewing experience on mobile devices, especially if the viewer is little more than a basic PDF.js library.

PDF.js and Mobile PDF Viewing

The open-source PDF.js library was originally designed for Mozilla’s Firefox browser, but it has become the basis for a broad range of PDF viewers due to its flexibility. That’s partly why the Accusoft PDF Viewer uses PDF.js as its foundation. However, one area where that versatility is sorely lacking is with regards to mobile support.

More specifically, PDF.js doesn’t supply a UI that is responsive for different screen types. It was designed to render PDFs to a conventional computer display and provides the expected tools needed to navigate a document using a keyboard and mouse interface. Even if developers were to incorporate the PDF.js library into their application, they would still need to build a new user interface for mobile devices. Otherwise, key mobile viewing features like touch scrolling and pinch to zoom would be handled not by the viewer, but by the device’s touchscreen interface. 

While this might sound like a small distinction, it can actually create serious problems when it comes to rendering the document at different zoom levels. Essential features like text search may also be rendered useless by the poor interface, and the lack of thumbnail previews could make navigating the document tedious.

Making a JS PDF Viewer Responsive

Today’s developers need viewing integrations that offer out-of-the-box mobile support to deliver a consistent viewing experience. That’s why we built upon the foundation of PDF.js to create a responsive viewer interface that instantly adapts to any screen size. Easily integrated into any web-based application, the Accusoft PDF Viewer immediately determines what type of device is being used when a document is opened. If it’s a mobile device, the viewer replaces the controls used for desktop viewing with dedicated mobile controls designed for a touchscreen. 

Key touch features like pinch-to-zoom allow users to interact with PDFs on mobile and tablet devices just as easily as they could with a mouse and computer screen. That usability is the key component of making a JS PDF viewer responsive. Mobile screens should never be treated like conventional screens. By integrating a mobile-ready viewer into their web application, developers can ensure viewing consistency across platforms while also allowing people to access documents where they want and when they want them.

Integrate Responsive PDF Viewing in a Snap

Building an application that includes a JS PDF viewer responsive to mobile screens is easier than ever thanks to Accusoft PDF Viewer. As a flexible JavaScript PDF library, it integrates quickly into any web-based application with just a few lines of code and no complicated server configurations. Our industry-leading expertise with imaging technology has allowed us to make substantial improvements to the way PDF.js renders PDF documents and ensure high levels of resolution regardless of zoom level or screen DPI.

To find out what Accusoft PDF Viewer can do for your application, download the Standard Version today at no cost and test its powerful viewing features in your development environment. With only a few lines of code, it’s the fastest way to add responsive PDF viewing to your web-based software solutions.

For expanded features like annotation markup tools, eSignature capabilities, UI customization, and white labeling, consider upgrading to Accusoft PDF Viewer Professional Version. Download our fact sheet for a detailed breakdown in available features.