Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Monday, August 27, 2018 4:52:40 PM(UTC)
Anthony Northrup

Groups: Registered, Tech Support, Administrators
Posts: 199

Was thanked: 28 time(s) in 28 post(s)

The LEADTOOLS v20 SDK supports both importing from and exporting to the FileNet P8 annotation format. For detailed information about this support, refer to the following page:
https://www.leadtools.com/help/leadtools/v20/dh/to/filenet-p8-and-daeja-annotations-support.html

The main method used for converting an AnnObject to a P8 annotation string is the AnnCodecs.ConvertToIBMP8 method. Here is a simplified snippet for converting an AnnObject to a P8 annotation string:
Code:

IBMP8WriteOptions writeOptions = new IBMP8WriteOptions()
{
    Formatted = true,
    ForMultiPageTiff = false,
    InferForMultiPageTiffFromMetadata = false,
    InferPageNumberFromMetadata = false,
    // Generally you'll want to pass screen resolution, and image resolution
    Mapper = new AnnContainerMapper(96, 96, 96, 96),
    PageNumber = 1
};
string p8AnnotationString = AnnCodecs.ConvertToIBMP8(annObject, writeOptions);

One major difference between the way the LEADTOOLS SDK handles annotations, and the P8 format is page numbers. Our annotations are added to an AnnContainer, and generally this is one AnnContainer per page of the original document. P8 annotations on the other hand each have their own page number, so when converting, we'll need to specify the page number for each annotation. This can be set with the PageNumber property of the IBMP8WriteOptions class.

Here is a complete sample function for converting a list of AnnContainers to a directory of P8 annotation files:
Code:

static void LEADToP8Directory(IEnumerable<AnnContainer> containers, string p8Directory)
{
	Directory.CreateDirectory(p8Directory);
	int page = 1;
	foreach (AnnContainer container in containers)
	{
		IBMP8WriteOptions writeOptions = new IBMP8WriteOptions()
		{
			Formatted = true,
			ForMultiPageTiff = false,
			InferForMultiPageTiffFromMetadata = false,
			InferPageNumberFromMetadata = false,
			Mapper = container.Mapper,
			PageNumber = page++
		};
		foreach (AnnObject annObject in container.Children)
		{
			// Provide a default guid
			if (String.IsNullOrEmpty(annObject.Guid))
				annObject.Guid = Guid.NewGuid().ToString();

			File.WriteAllText(
				Path.Combine(p8Directory, $"{annObject.Guid}.xml"),
				AnnCodecs.ConvertToIBMP8(annObject, writeOptions)
			);
		}
	}
}


Remark: For P8 to AnnObject conversion, refer to the following forum post:
https://www.leadtools.com/support/forum/posts/t12577-HOW-TO--Convert-P8-Annotation-Strings-to-LEADTOOLS--AnnObjects

Edited by user Monday, September 10, 2018 2:11:34 PM(UTC)  | Reason: Added link to reverse conversion

Anthony Northrup
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.109 seconds.