How to get checkmark value

  • 213 Views
  • Last Post 29 June 2018
  • Topic Is Solved
lx11020219 posted this 25 June 2018

Hello.

I want to obtain the value of the checkmark, but I could not get it with the attached file and code.
Where is wrong?

 

Code


// Engine Load...
document = engine.CreateFRDocument();
document.AddImageFile(strImagePath, null, null);
FREngine.FRPages pages = document.Pages;
FREngine.FRPage page = pages.Item(0);
FREngine.Layout layout = page.Layout;
FREngine.Region region = engine.CreateRegion();
region.AddRect(687, 558, 744, 608);
// Create a new block
FREngine.IBlock newBlock = layout.Blocks.AddNew(FREngine.BlockTypeEnum.BT_Checkmark, region, layout.Blocks.Count);
FREngine.CheckmarkBlock checkMarkBlock = newBlock.GetAsCheckmarkBlock();
checkMarkBlock.CheckmarkType = CheckmarkTypeEnum.CMT_Square;
checkMarkBlock.IsCorrectionEnabled = true;
// Set Layout
page.Layout = layout;
document.Pages.DeleteAt(0);
document.AddPage(page);
// Process
document.Recognize(null, null);
document.Synthesize(null);
// PDF Export
FREngine.PDFExportParams pdfParams = engine.CreatePDFExportParams();
pdfParams.Scenario = FREngine.PDFExportScenarioEnum.PES_Balanced;
document.Export(strPDFPath, FREngine.FileExportFormatEnum.FEF_PDF, pdfParams);
document.Close();
document = null;
// Engine Unload...

Attached Files

Order By: Standard | Newest | Votes
Daria Zvereva posted this 27 June 2018

Hello!

You may obtain the value of the checkmark after the Recognition stage using the CheckmarkState property of the CheckmarkBlock

Please, see the following code snippet:

// your code 
document.Recognize(null, null);
FREngine.FRPages pages = document.Pages;
FREngine.FRPage page = pages.Item(0);
FREngine.Layout layout = page.Layout;
FREngine.IBlock block = layout.Blocks.Item(layout.Blocks.Count - 1);
FREngine.CheckmarkBlock checkMarkBlock = block.GetAsCheckmarkBlock();
if (checkMarkBlock.CheckmarkState == FREngine.CheckmarkCheckStateEnum.CMCS_Checked)
{
      // do something
}
if (checkMarkBlock.CheckmarkState == FREngine.CheckmarkCheckStateEnum.CMCS_NotChecked)
{
     // do something
}
document.Synthesize(null);

You may also find the information in the Developer`s Help: Guided Tour→Advanced Techniques→Recognizing Checkmarks

Hope the information will be helpful!

lx11020219 posted this 28 June 2018

Hello.

Thank you for your reply.
I tried the sample code, but in the attached file the block Item of layout becomes 0 Counts.
Is it not recognized by FRE in the attached file?

Daria Zvereva posted this 28 June 2018

Checkmark block must be added to the document layout manually. You may do it with the code snippet from the first message. And then to get the value after recognition you should use the code snippet from the second post.

 So the full code sample:

// Engine Load...
document.AddImageFile(imagePath, null, null);
FREngine.FRPages pages = document.Pages;
FREngine.FRPage page = pages.Item(0);
FREngine.Layout layout = page.Layout;
FREngine.Region region = engineLoader.Engine.CreateRegion();
region.AddRect(687, 558, 744, 608);
// Create a new block
FREngine.IBlock newBlock = layout.Blocks.AddNew(FREngine.BlockTypeEnum.BT_Checkmark, region, layout.Blocks.Count);
FREngine.CheckmarkBlock checkMarkBlock = newBlock.GetAsCheckmarkBlock();
checkMarkBlock.CheckmarkType = FREngine.CheckmarkTypeEnum.CMT_Square;
checkMarkBlock.IsCorrectionEnabled = true;
// Set Layout
page.Layout = layout;
document.Pages.DeleteAt(0);
document.AddPage(page);               
// Process
document.Recognize(null, null);
// Get the recognized block
pages = document.Pages;
page = pages.Item(0);
layout = page.Layout;
FREngine.IBlock block = layout.Blocks.Item(layout.Blocks.Count - 1);
checkMarkBlock = block.GetAsCheckmarkBlock();
// Get the value
if (checkMarkBlock.CheckmarkState == FREngine.CheckmarkCheckStateEnum.CMCS_Checked)
{
   //do something
}
if (checkMarkBlock.CheckmarkState == FREngine.CheckmarkCheckStateEnum.CMCS_NotChecked)
{
   //do something
}

 

  • Liked by
  • lx11020219
lx11020219 posted this 29 June 2018

Thank you for answering.
I'm sorry, I missed the notation of "your code".
Check mark value was acquired with Sample Code.
It was very helpful.

Close