HIghlighting region in multipage pdf

  • 192 Views
  • Last Post 26 July 2018
  • Topic Is Solved
sam_starlord posted this 19 July 2018

I was working on highlighting text, but i found that we can only export that into image. i want a result for multi page searchable PDF with highlighted text.

if anyone can help, that will be much appreciated. thank you. 

PS: i m using FRengine 11

Order By: Standard | Newest | Votes
Helen Osetrova posted this 23 July 2018

Hello!

Please try to use methods of the imageModification object and the Modify method of the ImageDocument object as well. Take a look at the code sample below:

for (int i = 0; i < document.Pages.Count; i++)
{
  FREngine.LayoutBlocks blocks = document.Pages[i].Layout.Blocks;
  FREngine.ImageModification imageModification = engineLoader.Engine.CreateImageModification();
  FREngine.Region region = engineLoader.Engine.CreateRegion();

  for (int j = 0; j < blocks.Count; j++)
  {
      if (blocks[j].Type == FREngine.BlockTypeEnum.BT_Text)
      {
           FREngine.ITextBlock textBlock = blocks[j].GetAsTextBlock();
           FREngine.Paragraphs paragraphs = textBlock.Text.Paragraphs;

           foreach (FREngine.Paragraph par in paragraphs)
           {
                region.AddRect(par.Left, par.Top, par.Right, par.Bottom);
                imageModification.AddPaintRegion(region, 243 + 256 * 243 + 65536 * 21); // color = (red value) + (256 x green value) + (65536 x blue value)
                imageModification.AddReplaceBlackPixelsRegion(region, 0, 0);
           }

            document.Pages[i].ImageDocument.Modify(imageModification);
       }  
   }

   document.Pages[i].Synthesize();
}



document.Export(@"D:\Temp\Demo.pdf", FREngine.FileExportFormatEnum.FEF_PDF, null);

Hope this information will be helpful!

  • Liked by
  • sam_starlord
sam_starlord posted this 26 July 2018

thank you, i got my result and its working perfect.

Close