How to compare two pdf files through command line [closed]

南楼画角 提交于 2019-11-29 02:56:47

问题


Does anyone know how to compare two pdf files using adobe acrobat through command line. I want to do this via command line because we want to compare hundreds of file every day through some automated windows tasks.

Any kind of help will be greatly. I do not want to limit myself to acrobat to compare , if there is something else available.


回答1:


How about i-net PDFC - it does a full content comparison - text, images, lines, header/footer-detection and so on. You can use it either on command line or with a GUI (2.0, currently in public beta-phase).

The command-line tool already has the option to compare folders with PDFs against each other (or the extreme way: use the API ;))

Disclaimer: Yep, I work for the company who made this - so feedback highly appreciated.




回答2:


Check out comparepdf:

comparepdf is a command line tool for comparing two PDF files. By default it compares their texts but it can also compare them visually (e.g., to detect changes in diagrams, images, fonts, and layout). It should prove useful for automated testing.

It is Open Source (GPL) and there are Windows binaries available.

Also:

If you want a GUI application that shows the detailed differences between PDFs use DiffPDF instead.




回答3:


What you want simply cannot be done with Adobe Acrobat through the command line. However, you could do it with the help of some commandline utilities which you could unite into a shell or batch script.

1. Quick visual check for page image differences

One ingredient of this would be ImageMagick's convert command, which you can test like this for two 1-page PDF files which have page contents similar to each other's:

convert -label '%f' -density '100' first.pdf second.pdf -scale '100%' miff:- \
 | montage - -geometry +0+0 -tile 1x1 -background white miff:- \
 | animate -delay '50' -dispose background -loop 0 -

This will open a window which switches with a delay of 50 dezi-seconds between displaying each of the two files, so it is easy to discover visual differences.

2. Script to generate PDF output visualizing differences between PDF files

I'm doing the same thing using a shell script on Linux that wraps

  1. ImageMagick's compare command
  2. the pdftk utility
  3. Ghostscript (optionally)

(It would be rather easy to port this to a .bat Batch file for DOS/Windows.)

You can read details about this approach in this answer.



来源:https://stackoverflow.com/questions/11004524/how-to-compare-two-pdf-files-through-command-line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!