gpt4 book ai didi

java - PDFUtil : How to compare 2 pdf file with not same format and highlight the difference

转载 作者:太空宇宙 更新时间:2023-11-04 09:25:23 24 4
gpt4 key购买 nike

我想比较 2 个文件 PDF,现在我正在使用 PdfUtil 库。但我有一个问题,如果文件具有相同的格式,PdfUtil 仍然可以按预期工作。如果不是,结果图像将突出显示所有内容,我看不到两个文件之间的内容差异。那么,如何仅比较 TEXT_Mode 等内容,但仍然获得结果图像并突出显示 VISUAL_MODE 等差异谢谢 。这是我的简单代码

public static void main(String[] args) throws IOException {
String result ="/Users/abc/Downloads/Test";
String pdf1 = "/Users/abc/Downloads/pdf1.pdf";
String pdf2 = "/Users/abc/Downloads/pdf2.pdf";

PDFUtil pdfUtil = new PDFUtil();

pdfUtil.setCompareMode(CompareMode.VISUAL_MODE);
pdfUtil.highlightPdfDifference(true);
pdfUtil.setImageDestinationPath(result);
boolean abc =pdfUtil.compare(pdf1,pdf2);
System.out.print(abc);


}

最佳答案

你可以尝试https://github.com/lumpchen/xdiff.ncc ,一个基于pdfbox的pdf比较工具。

关于java - PDFUtil : How to compare 2 pdf file with not same format and highlight the difference,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57764898/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com