Punch-Hole Erase when ocr file

  • Last Post 27 September 2017
aravindb posted this 13 September 2017

    Is it possible to earse Punch-Hole marks when ocr files  using FR Engine 10 or 14, we have scanned documents with Punch-Hole marks on left and right side,but we cant say which location and size of mark.Is it possible to remove when ocr files.

Here i attach sample pdf file.

Attached Files

Order By: Standard | Newest | Votes
Nikolay Krivchanskiy posted this 21 September 2017

Hi Aravind,

For your issue we would recommend ImageDocument::Modify method. This method uses ImageModification object to update and change the ImageDocument.

You can use ImageModification::AddReplaceBlackPixelsRegion. Effectively replaces all black pixels in the set region.

For more information about ImageModification object, please refer to Help → API Reference → Image-Related Objects → ImageModification.

These holes are generally recognized as images, therefore you can use Layout::LayoutBlocks to remove them. You should iterate through blocks, returned by foresaid method, detect image blocks with coordinates left to or right to the rest of the text blocks, get their Block::Region and pass this region to ImageModification::AddReplaceBlackPixelsRegion.


If you do not intend to detect any other pictures, you can simply set PageAnalysisParams::DetectPictures to false, to effectively achieve the same result.

aravindb posted this 25 September 2017

  You have any sample code for this ? no need full code, just find and erase code, we will pass input file and output file.


Nikolay Krivchanskiy posted this 27 September 2017

Hi Aravind,

You can simply set PageAnalysisParams::DetectPictures to false, and then these punch-holes will not be present in output image.

Otherwise you will need to:

1. Get Layout using FRPage::Layout

2. Get all Blocks, using Layout::Blocks.

3. Get Leftmost and Rightmost coordinates of text blocks on the page using Block::Region and Region::Left/Region::Right.

4. Either:

a.Remove all picture blocks to the left of the Leftmost and to the right of the Rightmost. 

b.Create region from the left edge of the page to the Leftmost and from the right edge of the page to the Rightmost and add them to ImageModification::AddReplaceBlackPixelsRegion, after which call ImageDocument::Modify method.

5. Call FRPage::Synthesize.