# Can DVI files be converted to RTF files?

Consider a *NIX executable, `dvi2rtf`, whose contents are:

``````#!/bin/sh
TMPX=`mktemp /tmp/dvi2rtf.XXXXXX`
dvitty \$1 \$TMPX         # CTAN
txt2rtf \$TMPX \$2        # CTAN, in rtfutils
``````

If my head is working this morning and the right executables are on the PATH, this clobbers the second argument with an RTF file whose text contents will roughly correspond to those of the dvi file named by the first argument.

Such a program doesn't deserve the filename dvi2rtf, since it makes no attempt to preserve the formatting of the DVI file; Cf. Q#1621885: How to turn a dvi to tex. RTF's `\wpsp` can allow rtf to handle horizontal space similarly to DVI; RTF's notion of code pages is similar to how DVI handles fonts: maybe it is possible to handle other tricky features of dvi, such as vertical space?

Question: Is there such a program that attempts to preserve layout, however flaky? And if not, are there the RTF primitives to write a converter in a reasonable way?

-

## migrated from stackoverflow.comApr 18 '12 at 14:29

This question came from our site for professional and enthusiast programmers.

do you still have the latex source available? If not, not it's not possible. (Or at least harder than retyping the text) Look here for a similar question stackoverflow.com/questions/1620002/pdf-to-latex-linux –  Eduardo Leoni Dec 16 '09 at 15:03
With a sufficiently low quality threshold, it is certainly possible: the code I give usually yields intelligible text. Rtf has a different approach to laying out text -it's genuinely a markup language, while dvi is a plotting language- but I'm guessing it is possible to map dvi's layout onto rtf for most tex output, because rtf does allow some control over vertical and horizontal placement, and tex generally lays out characters line by line in the dvi. So, I'm optimistic. I think I'll have to implement it myself, though... –  Charles Stewart Dec 16 '09 at 15:24