0
点赞
收藏
分享

微信扫一扫

java pdf 出血检测

爱奔跑的读书者 2023-02-01 阅读 84


public static boolean isBleed(Map<String,Float> map){
Float left = map.get("left");
Float right = map.get("right");
Float top = map.get("top");
Float bottom = map.get("bottom");
return isAB(left,right)&&isAB(left,bottom)&&isAB(left,top);


}
public static boolean isAB(float a,float b){
return Math.abs(a-b)<0.01f;
}
public static Map<String,Float> getBleed(Rectangle media,Rectangle trim){
Map<String,Float> map = new HashMap<>();
float left = media.getLeft()/Shape.pt;
float right = media.getRight()/Shape.pt;
float top = media.getTop()/Shape.pt;
float bottom = media.getBottom()/Shape.pt;
float width = media.getWidth()/Shape.pt;
float height = media.getHeight()/Shape.pt;

if(trim==null){
map.put("left",left);
map.put("right",right-width);
map.put("top",top-height);
map.put("bottom",bottom);


}else{
float leftTrim = trim.getLeft()/Shape.pt;
float rightTrim = trim.getRight()/Shape.pt;
float topTrim = trim.getTop()/Shape.pt;
float bottomTrim = trim.getBottom()/Shape.pt;

map.put("left",leftTrim);
map.put("right",width-rightTrim);
map.put("top",height-topTrim);
map.put("bottom",bottomTrim);
}

return map;
}


举报

相关推荐

0 条评论