资源简介
基于PDFBox,根据指定字符串定位起始位置,然后进行指定区域的文本提取。代码较粗糙,供参考
代码片段和文件信息
package com.df.pdf.util;
import java.awt.Rectangle;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.text.PDFTextStripper;
import org.apache.pdfbox.text.PDFTextStripperByArea;
import org.apache.pdfbox.text.TextPosition;
public class ExtractTextByArea extends PDFTextStripper {
private int xBegin = 0;
private int yBegin = 0;
private int xEnd = 0;
private int yEnd = 0;
public int getxBegin() {
return xBegin;
}
public void setxBegin(int xBegin) {
this.xBegin = xBegin;
}
publ
评论
共有 条评论