Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

compare two pdf files (approach) using java [closed]

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?

like image 390
Alvin Avatar asked Nov 06 '25 08:11

Alvin


2 Answers

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/

like image 135
vins Avatar answered Nov 09 '25 02:11

vins


As you mentioned, pdfbox to extract its contents and then use google's diff to compare.

like image 41
Sajal Dutta Avatar answered Nov 09 '25 03:11

Sajal Dutta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!