Is there any tool that compares two dvi files. I would like to check if they are identical after I make some changes with source tex file.
TeX adds a comment into the DVI file, e.g.:
TeX output 2013.02.15:1010
It contains the date and time that complicates the comparison of the DVI files:
The time stamp can be set explicitly by setting
\time. If the two files for comparison have the same values, then the time stamp in the DVI files are the same and you can compare the files using the usual programs (
The comment has a fixed location in the DVI file format in the preamble. The fifteenth byte contains the length of the comment that follows. With the usual standard case, just ignore the first 42 bytes of the file. The missing values for numerator, denominator and magnification are repeated in the postamble anyway. In Linux the stripping could be done with
tailby setting option
-cto the file length minus 42.
Another possibility is
dvitypethat outputs the DVI contents in a more human readable manner, here the eigths line with the DVI comment and timestamp can be ignored in the comparison.
You can use
dvitype, that converts a DVI file to "human readable" form. The start of the obtained file is
This is DVItype, Version 3.6 (TeX Live 2012) Options selected: Starting page = * Maximum number of pages = 1000000 Output level = 4 (the works) Resolution = 300.00000000 pixels per inch numerator/denominator=25400000/473628672 magnification=1000; 0.00006334 pixels per DVI unit ' TeX output 2013.02.15:1014'
and so you should ignore the lines up to and including the last shown line with the time stamp that will surely be different.
The rest of the file will contain something like
Postamble starts at byte 353. maxv=41484288, maxh=26673152, maxstackdepth=13, totalpages=1 Font 14: cmtt10---loaded at size 655360 DVI units Font 7: cmr10---loaded at size 655360 DVI units 42: beginning of page 1 87: down4 41484288 v:=0+41484288=41484288, vv:=2628 92: push level 0:(h=0,v=41484288,w=0,x=0,y=0,z=0,hh=0,vv=2628) 93: down4 -39649280 v:=41484288-39649280=1835008, vv:=116 98: down4 37683200 v:=1835008+37683200=39518208, vv:=2503 103: push ...
that are low level instructions for associating fonts to a unique number and for setting type on the pages.
dvii utility can calculate message digest for each page, e.g.
dvii -p -M1 filex > before.md cat before.md [message digest: simple sum (ignore font)] p:[1/1]::9C8E26458F1B019011D2F28DA18B18CC p:[2/2]::9C8E26468F1B029011D2F28DA18B18CC p:[3/3]::9C8E26478F1B039011D2F28DA18B18CC p:[4/4]::9C8E26488F1B049011D2F28DA18B18CC
You can then compare
.md files, instead of