LEADTOOLS Support
Document
Document SDK Examples
HOW TO: Create a Multipage Annotation Redaction Tool
#1
Posted
:
Wednesday, April 5, 2017 4:25:36 PM(UTC)
Groups: Manager, Tech Support, Administrators
Posts: 218
Was thanked: 12 time(s) in 12 post(s)
Attached is a demo written in C# in .NET4 VS 2017 that shows how to use the ImageViewer Control as well as the Annotations SDK to navigate through a multipage input document, add redaction objects to the document, and then flatten and save out the document as 300x300 8.5inx11in regardless of what the input size was.
To run this project, make sure the output path is set to
Quote:C:\LEADTOOLS 19\Bin\Dotnet4\Win32
and you have a non-expired license in
Quote:C:\LEADTOOLS 19\Common\License
Here is the relevant code for each part:
Adding a container for each page contained in the image viewer:Code: //Add an Annotation Container for each page to the Container Collection
pageContainers.Clear();
for (int page = 1; page <= imageViewer.Image.PageCount; page++)
{
AnnContainer pageContainer = new AnnContainer();
pageContainer.Mapper.MapResolutions(imageViewer.Image.XResolution,
imageViewer.Image.YResolution,
imageViewer.Image.XResolution,
imageViewer.Image.YResolution);
pageContainer.Size = pageContainer.Mapper.SizeToContainerCoordinates(imageViewer.ImageSize.ToLeadSizeD());
pageContainers.Add(pageContainer);
}
//Attach the first container to the annAutomation
annAutomation.AttachContainer(pageContainers.FirstOrDefault(c => pageContainers.IndexOf(c) + 1 == imageViewer.Image.Page), null);
Resize and burnCode://Burn each container to each page and then resize it to 300x300 DPI 8.5inx11in
RasterImage flatImage = null;
for (int page = 0; page < imageViewer.Image.PageCount; page++)
{
imageViewer.Image.Page = page + 1;
AnnWinFormsRenderingEngine renderer = annManager.RenderingEngine as AnnWinFormsRenderingEngine;
RasterImage flatPage = renderer.RenderOnImage(pageContainers[page], imageViewer.Image.Clone());
flatPage.XResolution = 300;
flatPage.YResolution = 300;
SizeCommand size = new SizeCommand()
{
Flags = RasterSizeFlags.Bicubic,
Height = 3300,
Width = 2550
};
size.Run(flatPage);
if (flatImage == null)
flatImage = flatPage;
else
flatImage.AddPage(flatPage);
}
//Save the final FlatImage to disk
using (RasterCodecs codecs = new RasterCodecs())
codecs.Save(flatImage, dlg.FileName, RasterImageFormat.RasPdfG4, 1);
//Reset the page back to the first page
imageViewer.Image.Page = 1;
Update:This updated project has configurations for LEADTOOLS 19 and LEADTOOLS 20. Code changes between the two are negligible.
Edited by moderator Wednesday, June 20, 2018 8:54:09 AM(UTC)
| Reason: Not specified
Hadi Chami
Developer Support Manager
LEAD Technologies, Inc.
LEADTOOLS Support
Document
Document SDK Examples
HOW TO: Create a Multipage Annotation Redaction Tool
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.