|
@@ -66,42 +66,35 @@ public class PDFUtils {
|
|
|
return eVisaConfigList;
|
|
|
}
|
|
|
*/
|
|
|
+public static void main11(String[] args) {
|
|
|
+ String data = "/Users/hongchuangyanfa/Desktop/excel/123456.xlsx";
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
public static synchronized List<String> getPdfSignIds(String pdfUrl) {
|
|
|
PdfDocument pdf = new PdfDocument();
|
|
|
List<String> eVisaConfigList = new ArrayList<>();
|
|
|
try {
|
|
|
URL url =new URL(pdfUrl);
|
|
|
-/* URLConnection conn = url.openConnection();
|
|
|
- conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
|
|
|
- //加载PDF文档
|
|
|
- System.out.println("-------getid------"+pdfUrl);
|
|
|
- conn.setConnectTimeout(30000);
|
|
|
- conn.setConnectTimeout(60000);
|
|
|
- InputStream ossInputStream = conn.getInputStream();
|
|
|
- Is
|
|
|
- pdf.loadFromStream(ossInputStream);*/
|
|
|
byte[] byteArray = IOUtils.toByteArray(url);
|
|
|
pdf.loadFromBytes(byteArray);
|
|
|
- /*if (conn instanceof HttpURLConnection) {
|
|
|
- ((HttpURLConnection) conn).disconnect();
|
|
|
- }*/
|
|
|
for(int i= 0;i<pdf.getPages().getCount();i++){
|
|
|
PdfPageBase page = pdf.getPages().get(i);
|
|
|
PdfTextFindCollection allText = page.findAllText();
|
|
|
PdfTextFind[] finds = allText.getFinds();
|
|
|
for(int k=0;k<finds.length;k++){
|
|
|
String textStr = finds[k].getMatchText();
|
|
|
+ if(textStr.indexOf("*")>=0){
|
|
|
+ textStr = textStr.substring(textStr.lastIndexOf("*")+1,textStr.length());
|
|
|
+ }
|
|
|
if (textStr.length() >= 15 && Func.isNumeric(textStr)) {
|
|
|
eVisaConfigList.add(textStr);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- // ossInputStream.close();
|
|
|
List<String> unique = eVisaConfigList.stream().distinct().collect(Collectors.toList());
|
|
|
-
|
|
|
return unique;
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
@@ -122,14 +115,12 @@ public class PDFUtils {
|
|
|
|
|
|
for(int i= 0;i<pdf.getPages().getCount();i++){
|
|
|
PdfPageBase page = pdf.getPages().get(i);
|
|
|
- // System.out.println( page.extractText(true));
|
|
|
String text= page.extractText(false);
|
|
|
PdfTextFindCollection allText = page.findAllText();
|
|
|
PdfTextFind[] finds = allText.getFinds();
|
|
|
for(int k=0;k<finds.length;k++){
|
|
|
String textStr = finds[k].getMatchText();
|
|
|
if (textStr.length() >= 15 && Func.isNumeric(textStr)) {
|
|
|
- System.out.println(textStr);
|
|
|
eVisaConfigList.add(textStr);
|
|
|
}
|
|
|
}
|