Community

HIghlighting region in multipage pdf Answered

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

0

Comments

2 comments

  • Avatar
    Helen Osetrova

    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!

    1
    Comment actions Permalink
  • Avatar
    sam_starlord

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

    0
    Comment actions Permalink

Please sign in to leave a comment.