Changing Text or highlight color in Export to PDF or .docx

  • 319 Views
  • Last Post 09 November 2016
  • Topic Is Solved
dfsT posted this 07 November 2016

I am using ABBYY FRE 11 with .Net.

I PreProcess/Analyze/Recognize/Synthesize input images/documents with recognizerParams (SaveCharacterRecognitionVariants, SaveWordRecognitionVariants, SaveCharacterRegions, and ExactConfidenceCalculation) set to true and ErrorHighlightLevel set to EHL_Thorough.

I then Loop through all paragraphs, get CharacterParams, and when a character is marked as suspicious, I set new parameters for the character that should change the text color to red (I tried changing the color and FontStyle.Color properties of CharacterParams). The CharacterParams for the suspicious characters are set like this:

prgh.SetCharParams(i, 1, charParams, 0x00000100, 0x100000); //CFL_IsSuspicious , StyleParamsEnum.SF_Color)
Where i is the index of the suspicious character.

When exporting to .PDF and .Docx formats, this does not happen. I have monochrome turned off and TextOnImage turned on for PDF Export. For RTF export, I turned on HighlightErrorsWithBackgroundColor set to true, so suspicious characters in exported .docx files will be highlighted green (this does happen).

How do I change the parameters/settings to change the textcolor of suspicious characters, or at least get highlighting to occur on PDF export? If more clarity is needed I will post code snippets.

Oksana Serdyuk posted this 09 November 2016

Hi,

To check is a character was uncertainly recognized and to change its color, please use the following objects, properties and methods provided by the FineReader Engine API:

  • the IParagraph::GetCharParams() method, the CharParams object and its property ICharParams::IsSuspicious to check which characters were uncertainly recognized,
  • the IParagraph::SetCharParams() method and the ICharParams::Color property to set the color of the uncertainly recognized characters.

See the Developer’s Help file articles API Reference→Text-Related Objects→Paragraph and API Reference→Text-Related Objects→CharParams for more information.

Also I have just tested this usage scenario using the RecognizedTextProcessing standard C# sample, which you can find in the %ProgramData%\ABBYY\SDK\11\FineReader Engine\Samples\Visual CS\RecognizedTextProcessing folder. I have modified the code a little:

1) add export to the DOCX and PDF formats in the processImage() method:

private void processImage()
{
       // Create document
       FRDocument document = engineLoader.Engine.CreateFRDocument();

       try {
              …
              // Save results
              displayMessage("Saving results...");
              document.Export(Path.Combine(FreConfig.GetSamplesFolder(), @"SampleImages\Demo.docx"), FREngine.FileExportFormatEnum.FEF_DOCX, null);

              FREngine.PDFExportParams pdfParams = engineLoader.Engine.CreatePDFExportParams();
              pdfParams.TextExportMode = FREngine.PDFExportModeEnum.PEM_TextOnImage;
              document.Export(Path.Combine(FreConfig.GetSamplesFolder(), @"SampleImages\Demo.pdf"), FREngine.FileExportFormatEnum.FEF_PDF, pdfParams);

              //show calculated statistics
              displayStatistics();
       } catch( Exception error ) {
       …
       }
}

2) add changing of the color for the suspicious characters in the calculateStatisticsForChar() method:

void calculateStatisticsForChar( Paragraph paragraph, int charIndex )
{
       CharParams charParams = engineLoader.Engine.CreateCharParams();
       paragraph.GetCharParams( charIndex, charParams );
       if( charParams.IsSuspicious )
       {
              suspiciousSymbolsCount++;
              charParams.Color = 255;
              paragraph.SetCharParams(charIndex, 1, charParams, 0x00000100, 0x100000);
        }
…
}

And get the following results:

alt text

Attached Files

Close