This is a follow-up to Can LaTeX be persuaded to produce text output?. Having discovered that pdftotext is the way to go, I'm curious as to whether it is possible to have TeX invoke that command on the PDF after the PDF has been finished (presumably via some write18 hackery). So this is close to Is it possible to compile a *TeX document with a single command? except that I simply want to run the equivalent of
pdflatex doc.tex; pdftotext doc.pdf
but wholly from within TeX. So it's sort of what I understand xelatex does with its producing the dvi first and then converting it to pdf.
This is just idle curiosity, I fully realise that the shell command I gave above is almost certainly the easiest way of doing this, and that in explaining to others what to do (as I expect to have to do with this project) then the above will be simpler than "Run pdflatex with the -enable-shell-escape option.".
To make this different from Taco's answer to Is it possible to compile a *TeX document with a single command?, I'd like to be able to hide this from the user in a style file.