Technical FAQs

Question

ImageGear .NET v24.6 added support for viewing PDF documents with XFA content. I’m using v24.8, and upon trying to open an XFA PDF, I get a SEHException for some reason…

SEHException

Why might this be happening?

Answer

One reason could be because you need to execute the following lines after initializing the PDF component, and prior to loading an XFA PDF:

// Allow opening of PDF documents that contain XFA form data.
IImGearFormat pdfFormat = ImGearFileFormats.Filters.Get(ImGearFormats.PDF);
pdfFormat.Parameters.GetByName("XFAAllowed").Value = true;

This will enable XFA PDFs to be opened by the ImageGear .NET toolkit.

Question

I want to re-arrange the page order of a PDF. I’ve tried the following…

var page = imGearDocument.Pages[indx].Clone();

imGearDocument.Pages.RemoveAt(indx); //// Exception: "One or more pages are in use and could not be deleted."

imGearDocument.Pages.Insert(newIndx, page);

But an exception is thrown. Somehow, even though the page was cloned, the exception states that the page can’t be removed because it’s still in use.

What am I doing wrong here?

Answer

If you’re using an older version of ImageGear .NET, you may run into this exception when you clone the page. Some of the resources between the original and the clone are still shared, which is why this happens.

Starting with ImageGear .NET v24.8, this no longer happens, and the above code should work fine.

If you still need to use the earlier version, you can use the InsertPages method instead.

Question

In ImageGear, why am I running into AccessViolationExceptions when I run my application in parallel?

Answer

This issue can sometimes occur if ImGearPDF is being initialized earlier in the application. In order to use ImGearPDF in a multi-threaded program, it needs to be initialized on a per-thread basis. For example, if you have something like this:

ImGearPDF.Initialize();
Parallel.For(...)
{ 
    // OCR code
}
ImGearPDF.Terminate();

Change it to this:

Parallel.For(...)
{
    ImGearPDF.Initialize();
    // OCR code
    ImGearPDF.Terminate();
}

The same logic applies to other ImageGear classes, such as ImGearPage instances or the ImGearRecognition class – you should create one instance of each class per thread, rather than creating a single instance and accessing it across threads. In the case of the ImGearRecognition class, you’ll have to use the createUnique parameter to make that possible e.g.:

ImGearRecognition recEngine = ImGearRecognition(true);

instead of

ImGearRecognition recEngine = ImGearRecognition();

document management bank

The COVID-19 crisis has permanently changed the way banks do business. While many financial firms were already shifting away from brick-and-mortar branches toward both mobile and digital alternatives, pervasive pandemic priorities required a rapid shift in physical presence — forcing companies to rapidly react with remote work alternatives.

Some — such as JPMorgan — were already prepping for potential shifts in early March, deploying a pilot project that saw 10% of its 125,000 employees working from home. Banks like BMO, meanwhile, have embraced the new normal. The company says that around 36,000 staff members may permanently split their time between home and corporate offices. 

While this focus on employee efficacy and engagement is critical, productive people aren’t the only element of remote work success. Security and speed are two of the qualities that consumers now expect across all key banking functions, and firms must prioritize digital processes that streamline these processes without compromising financial requirements. 

But what does this look like in practice? How do organizations handle document management, process automation, and employee collaboration at a distance — without breaking the bank?


Facing Financial Frustrations

When work-from-home went from “maybe” to mandate, Deutsche Bank found itself racing to keep up. With just a few thousand out of its 90,000-strong workforce already working remotely, the firm was under pressure to scale capabilities quickly — from reimbursing staff for device purchase to rolling out video conferencing tools for more than 50,000 employees in less than two weeks, the bank has been under pressure to deliver remote work processes that deliver both continuity and compliance.

With finance firms historically lagging on technology adoption, however, this presents a significant problem. While cloud-based communication and collaboration tools are now commonplace — and can be readily adapted to work-from-home environments — the tools and tech necessary to underpin key financial functions are often tied to in-house server stacks and legacy applications. 

This creates a digital disconnect. While staff may have access to corporate networks, many of the secure document management and financial processing solutions they need to complete day-to-day operations simply weren’t designed to operate at a distance. Security accounts for part of this separation — regulatory control is critical for banks to ensure client privacy — but many banks have also focused on familiarity over functionality, adopting a “good enough” approach to cumbersome, on-site applications. As a result, firms now face financial frustration across critical workflows, including:

  • Consumer Vetting — How do banks effectively evaluate potential client credit histories and financial foundations to deliver tailored service recommendations at a distance? Insecure credit or personal data access could have significant regulatory and legal repercussions.
  • Credit Approvals — Necessary credit checks require secure connections and the assurance that data won’t be subject to theft or man-in-the-middle attacks.
  • Loan Applications — Bank staff must complete complex forms at a distance and firms must ensure work-from-home employees have the tools they need to handle multiple file formats.
  • Account Management — Opening, closing, and modifying account information requires secure access and the ability to share key documents with specific data removed or redacted. Financial data shared outside secure workflows could result in compliance failures.

 


Solving for Scale

While many big banks are preparing partial return-to-work strategies or ramping up remote work solutions, smaller financial firms don’t have this luxury. The scale of large enterprises affords bigger budgets for IT management and deployment, giving them a deeper pool of resources to pull from when deciding how best to support staff and systems at a distance. From in-house IT teams capable of creating custom-built apps to legacy software solutions that can be updated to work with new collaboration tools, the scale of big banks offers a marked advantage.

For smaller financial firms with the bulk of their workforce already at home and a return to the office unlikely in the near future, fragmentation is the familiar framework. Many SMEs now use multiple document management applications to streamline key processes — but these apps don’t always work well together.

In the office, this doesn’t pose a significant problem — staff might lose time switching between software tools or moving data across digital divides — but at home, access and agility are both restricted. This becomes more complicated thanks to the rise of multi-cloud computing. While purpose-built cloud services empower small banks to keep pace with their enterprise counterparts, they introduce complexity as access points both multiply and diversify.


Driving Digital Dividends

To drive digital dividends at a distance, smaller banks are well-served by the implementation of advanced software development kits (SDKs) and application programming interfaces (APIs). These tools make it possible to integrate advanced functionality into existing apps without compromising the security of critical banking data. To deliver remote work potential, firms need SDKs capable of:

  • Collaboration Integrate key collaboration functions including in-app document viewing to enhance data security, easy annotation and commenting options to ensure all staff are on the same page for multi-step application or approval processes, and burn-in redaction to enhance the protection of client or corporate data. 
  • ConversionAs complex, compliance-heavy processes such as loan applications, credit evaluations, and financial investments move to remote, on-demand models, banks need no-touch data processing that makes it possible to view multiple file types — including familiar Word and Excel files along with more specialized image formats — and convert these files to PDF documents for easy search. 
  • Capture Automated data capture, field recognition, and forms processing not only reduce the amount of time staff spend creating new forms and completing current applications, they also reduce the risk of human error. Enable your team to take complete control of document management functions with powerful character recognition, scanned document cleanup, and form identification — all from within your own application.

The “new normal” for banking relies on digital services. Advanced SDKs and APIs make it possible for firms to succeed over both time and distance by delivering comprehensive collaboration, conversion, and data capture without breaking the bank.

Question

How do I ensure temp files are deleted when closing ImageGear .NET?

Answer

All PDF objects are based on underlying low-level PDF objects that are not controlled by .NET resource manager and garbage collector. Because of this, each PDF object that is created from scratch should be explicitly disposed of using that object’s Dispose() method.

Also, any ImGearPDEContent object obtained from ImGearPDFPage should be released using the ImGearPDFPage.ReleaseContent() in all cases.

This should cause all temp files to be cleared when the application is closed.

Question

I am combining multiple PDF documents together, and I need to create a new bookmark collection, placed at the beginning of the new document. Each bookmark should go to a specific page or section of the new document.
Example structure:

  • Section 1
    • Document 1
  • Section 2
    • Document 2

How might I do this using ImageGear .NET?

Answer

You are adding section dividers to the result document. So, for example, if you are to merge two documents, you might have, say, two sections, each with a single document, like so…

  • Section 1
    • Document 1
  • Section 2
    • Document 2

…The first page will be the first header page, and then the pages of Document 1, then another header page, then the pages of Document 2. So, the first header page is at index 0, the first page of Document 1 is at index 1, the second header is at 1 + firstDocumentPageCount, etc.

The following code demonstrates adding some blank pages to igResultDocument, inserting pages from other ImGearPDFDocuments, and modifying the bookmark tree such that it matches the outline above, with "Section X" pointing to the corresponding divider page and "Document X" pointing to the appropriate starting page number…

// Create new document, add pages
ImGearPDFDocument igResultDocument = new ImGearPDFDocument();
igResultDocument.CreateNewPage((int)ImGearPDFPageNumber.BEFORE_FIRST_PAGE, new ImGearPDFFixedRect(0, 0, 300, 300));
igResultDocument.InsertPages((int)ImGearPDFPageNumber.LAST_PAGE, igFirstDocument, 0, (int)ImGearPDFPageRange.ALL_PAGES, ImGearPDFInsertFlags.DEFAULT);
igResultDocument.CreateNewPage(igFirstDocument.Pages.Count, new ImGearPDFFixedRect(0, 0, 300, 300));
igResultDocument.InsertPages((int)ImGearPDFPageNumber.LAST_PAGE, igSecondDocument, 0, (int)ImGearPDFPageRange.ALL_PAGES, ImGearPDFInsertFlags.DEFAULT);

// Add first Section
ImGearPDFBookmark resultBookmarkTree = igResultDocument.GetBookmark();
resultBookmarkTree.AddNewChild("Section 1");
var child = resultBookmarkTree.GetLastChild();
int targetPageNumber = 0;
setNewDestination(igResultDocument, targetPageNumber, child);

// Add first Document
child.AddNewChild("Document 1");
child = child.GetLastChild();
targetPageNumber = 1;
setNewDestination(igResultDocument, targetPageNumber, child);

// Add second Section
resultBookmarkTree.AddNewChild("Section 2");
child = resultBookmarkTree.GetLastChild();
targetPageNumber = 1 + igFirstDocument.Pages.Count;
setNewDestination(igResultDocument, targetPageNumber, child);

// Add second Document
child.AddNewChild("Document 2");
child = child.GetLastChild();
targetPageNumber = 2 + igFirstDocument.Pages.Count;
setNewDestination(igResultDocument, targetPageNumber, child);

// Save
using (FileStream stream = File.OpenWrite(@"C:\path\here\test.pdf"))
{
    igResultDocument.Save(stream, ImGearSavingFormats.PDF, 0, 0, igResultDocument.Pages.Count, ImGearSavingModes.OVERWRITE);
}

...

private ImGearPDFDestination setNewDestination(ImGearPDFDocument igPdfDocument, int targetPageNumber, ImGearPDFBookmark targetNode)
{
    ImGearPDFAction action = targetNode.GetAction();
    if (action == null)
    {
        action = new ImGearPDFAction(
            igPdfDocument,
            new ImGearPDFDestination(
                igPdfDocument,
                igPdfDocument.Pages[targetPageNumber] as ImGearPDFPage,
                new ImGearPDFAtom("XYZ"),
                new ImGearPDFFixedRect(), 0, targetPageNumber));
        targetNode.SetAction(action);
    }
    return action.GetDestination();
}

(The setNewDestination method is a custom method that abstracts the details of adding the new destination.)

Essentially, the GetBookmark() method will allow you to get an instance representing the root of the bookmark tree, with its children being subtrees themselves. Thus, we can add a new child to an empty tree, then get the last child with GetLastChild(). Then, we can set the action for that node to be a new "GoTo" action that will navigate to the specified destination. Upon save to the file system, this should produce a PDF with the below bookmark structure…

Bookmarks example

Note that you may need to use the native Save method (NOT SaveDocument) described in the product documentation here in order to save a PDF file with the bookmark tree included. Also, you can read more about Actions in the PDF Specification.