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 : Wednesday, April 5, 2017 4:25:36 PM(UTC)

Hadi  
Hadi

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 burn
Code:
//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;


File Attachment(s):
MinRedactDemo.zip (14kb) downloaded 186 time(s).


Update:
This updated project has configurations for LEADTOOLS 19 and LEADTOOLS 20. Code changes between the two are negligible.
File Attachment(s):
MinRedactDemo_v19_v20.zip (15kb) downloaded 60 time(s).

Edited by moderator Wednesday, June 20, 2018 8:54:09 AM(UTC)  | Reason: Not specified

Hadi Chami
Developer Support Manager
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.047 seconds.