thoqbk / traprange Goto Github PK
View Code? Open in Web Editor NEW(Java)A Method to Extract Tabular Content from PDF Files
License: MIT License
(Java)A Method to Extract Tabular Content from PDF Files
License: MIT License
The only JAR available is packaging log4J implementation and it is forcing to use log4j as active logger in the projects using this.
I've been using this JAR with Spring Boot v2.2.5.RELEASE successfuly. I wanted to use current version 3.0.6 which benefits from way more recent java version and API but... I keep having exception saying I have to remove log4j logger factories from classpath if I want to use Logback.
I finally rolled back to v2.2.5.RELEASE to keep working.
This would not be a problem if it were published on maven repository (#19 ) I guess.
Please would it be ok to put a JAR without depdendencies in your repo ?
Most tables do not occupy the whole pdf page. Can an argument be added so that users can specify the table position in the pdf? Only the region specified by the users is processed, instead of the whole pdf page.
I tried the code with my pdf's, result was amazing. I found that rows are getting extracted but the problem is that columns are not getting extracted.
Hi a. Tho,
Currently, I'm using "get" method to get PDF data from specific page. I wonder that can we get all PDF data at once instead of getting data page by page like that?
My code:
public static int rowNumberOfPDFFile(String pdfLink, int pagePDFNumber) throws IOException {
PDFTableExtractor extractor = new PDFTableExtractor();
List
html = html.substring(html.indexOf("border='1'>") + 11);
int rowNumber = org.apache.commons.lang3.StringUtils.countMatches(html, "/tr");
return rowNumber;
}
I would like to get all PDF data into "html" field. Could you please help?
Thanks,
Phan Nguyen
Hi. This is a really great package. Thanks so much.
I'm having one issue with exporting to CSV:
String csv = tables.get(0).toString();
I have a PDF table where the first column is sometimes empty. TrapRange discovers the column just fine, and export to HTML shows the column with the empty cell. But when I export to CSV, the empty cells are lost with no starting semicolon to denote them.
Do you experience the same?
Mike
Hi, I noticed that page numbers are read incorrect from command line options like -p
-ep
and -el @
.
I made sort-of-a-workaround in commit dc99b6c , but I actually think that it's better to fix either options parsing or page number checks in PDFTableExtractor#extract
Hi,
Nice work! Are you planning to migrate to pdfbox 2.0??
The new API has vastly improved and it would be a big plus for the users wishing to migrate to pdfbox 2.0, since many functions have moved/been deleted along with some classes.
Would love to hear back!
Cheers
In PDF attached first cell at header table is (Dell-EMC Part) and after using extraction it become (DPaerllt-EMC)
can you please check it
While implementing the extractor on a main java method, I get the following error:
java.lang.NoSuchMethodError: com.google.common.collect.Range.closed(Ljava/lang/Comparable;Ljava/lang/Comparable;)Lcom/google/common/collect/Range;
The program is as follows:
PDFTableExtractor extractor = new PDFTableExtractor();
extractor = extractor.setSource("C:/test.pdf");
extractor.addPage(0);
extractor.exceptLine(0, new int[]{0, 1});
List<Table> tables = extractor.extract();
try (Writer writer = new OutputStreamWriter(new FileOutputStream("C:/Users/rys_s/Documents/MiArchivo.html"), "UTF-8")) {
for (Table table : tables) {
writer.write("Page: " + (table.getPageIdx() + 1) + "\n");
writer.write(table.toHtml());
}
}
And the error comes apparently at the extractor.extract()
line.
hi
is it possible to run this app on ubuntu 15.10 ? (from command line)
thanks
though i have given the path of the file its giving error as Missing input file..
Can u please update with this?
The method sort(new Comparator(){}) is undefined for the type List<Range> TESTPDFBox.java line 54
running java version 8 update 91
When including the traprange jar in a project with selenium-java 3.12.0 in maven, the Guava version 18 conflicts. Attempting to instantiate a ChromeDriver object results in the following error:
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:124)
at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:33)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:139)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:335)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:89)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123)
Solution is to use a more recent version of Guava.
how can i get csv file as an output? just by giving output file as .csv file?
i tried it by giving like that and getting even html cells like tr,td in the csv file.
how can i avoid getting those in the csv file?
I am actually working on something to automatize the process of reading pdf tabs, the fact is that i actually get only on big collum with multiple row, while trying to dive into the process i actually saw that after extracting the TextPositions in the PDFTableExtractor.java class I get only one character by text position, where I suppose we are waiting to get a full cell, is this where my problem come from?
here is an example tab from my tests, there is also tons of empty columns and row that I delete myself in front.
In Method PdfTableExtractor.extract()
there is the following line
this.document = PDDocument.load(this.inputStream);
This no longer works. There is a new way to load the file
Loader.loadPDF(File file);
Hi, thoqbk! I have downloaded the repository and I find there existing some error when use maven to packaging the jar. The error message are as follows:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /E:/Repo/traprange-master/src/test/java/com/giaybac/traprange/test/TESTP
DFBox.java:[57,15] 找不到符号
符号: 方法 sort(<匿名java.util.Comparator<com.google.common.collect.Range>>)
位置: 类型为java.util.List<com.google.common.collect.Range<java.lang.Integer>>
的变量 ranges
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.129 s
[INFO] Finished at: 2015-11-18T12:03:09+08:00
[INFO] Final Memory: 14M/310M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.
1:testCompile (default-testCompile) on project traprange: Compilation failure
[ERROR] /E:/Repo/traprange-master/src/test/java/com/giaybac/traprange/test/TESTP
DFBox.java:[57,15] 找不到符号
[ERROR] 符号: 方法 sort(<匿名java.util.Comparator<com.google.common.collect.Ra
nge>>)
[ERROR] 位置: 类型为java.util.List<com.google.common.collect.Range<java.lang.Int
eger>>的变量 ranges
I continue to move the project into Eclipse. After I fixed the libraries settings according to the pom.xml and import suggestions, the following code in PDFTableExtractor.java are suggested wrong.
this.textPositions.sort(new Comparator<TextPosition>() {
This appeared in many other java files, e.g. TrapRangeBuilder, and TESTPDFBox. And here is the Eclipse suggestion:
The method sort(new Comparator<Range>(){}) is undefined for the type List<Range<Integer>>
Could you make it clear how you implement the sort method?
Thank you very much.
Win 7 x64
Apache Maven 3.3.3
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)
It would be really nice to have this library available in public Maven repo.
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.