i need to write a java class that compares two pdf files and points out the differences(differences in text/position/font) using some sort of highlighting. my initial approach was use pdfbox to parse the file using pdfbox and store the extracted text using in some data structure that would help me with comparing. Is there any java library that can extract the text,preserve the formatting,help me with indexing and comparing.Can i use tika/ google's diff-match for this. tika extracts text in the form of xhtml but how can i compare two xhtml files?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Refer the below given sample code for pdf comparison.
zeonpad provided the free java api for pdf comparison.
I had to compare tons of pdf files in my project. my requirement was to compare the pdf files by pixel by pixel. After a lot of googling and as i could not find anything good, I ended up creating my own pdf utility for this purpose.
Please check this blog for more details & jar download.
http://www.testautomationguru.com/introducing-pdfutil-to-compare-pdf-files-extract-resources/
Check this post on comparing PDF documents. Take note of the line;
As you mentioned, pdfbox to extract its contents and then use google's diff to compare.
I don't know if you were able to solve your problem. Here is my approach to solve this.
First let's convert PDFs to HTMLs using Pdf2dom and then use daisydiff to generate comparison report in HTML. If you want a PDF then convert that HTML report to PDF. But keep in mind that PDF to HTML conversion is not 100% accurate due to complexities in PDF. You can also try another approach of converting PDFs to images and compare pixel to pixel and generate a PDF report. You can try PDFcompare library. It looks promising to me. Let me know if anyone already tried this.