org.eadge.extractpdfexcel.tools.DefaultBlockRemover Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pdf-to-excel Show documentation
Show all versions of pdf-to-excel Show documentation
A Java library used to convert PDF to Excel.
The newest version!
package org.eadge.extractpdfexcel.tools;
import org.eadge.extractpdfexcel.data.block.Block;
import org.eadge.extractpdfexcel.data.geom.Rectangle2;
import org.eadge.extractpdfexcel.models.BlockRemover;
import java.util.Collection;
import java.util.Iterator;
/**
* Created by eadgyo on 19/07/16.
*
* Remove block if it already exists
*/
public class DefaultBlockRemover extends BlockRemover
{
/**
* Bounds of the extracted pdf
*/
private Rectangle2 bounds;
/**
* @param bounds bound delimiting valid blocks.
*/
public DefaultBlockRemover(Rectangle2 bounds)
{
this.bounds = bounds;
}
@Override
public void removeBlock(Collection blocks)
{
for (Iterator iterator = blocks.iterator(); iterator.hasNext(); )
{
Block block = iterator.next();
if (!bounds.areColliding(block.getBound()))
{
iterator.remove();
}
}
}
}