| 1 |
|
| 2 |
\setupoutput[pdftex] |
| 3 |
|
| 4 |
\starttext |
| 5 |
|
| 6 |
|
| 7 |
\chapter{Controlling Acrobat Reader under X11} |
| 8 |
|
| 9 |
|
| 10 |
\centerline{Taco Hoekwater, taco(at)aanhet.net} |
| 11 |
|
| 12 |
\blank[3*line] |
| 13 |
|
| 14 |
Most people who use the Acrobat Reader to preview PDF files |
| 15 |
generated from \TeX\ documents will know that it is a hassle to |
| 16 |
deal with documents that need to be compiled while being viewed. |
| 17 |
|
| 18 |
The Linux version of Adobe's program simply does not notice that the |
| 19 |
PDF file has changed, and the Microsoft Windows version is even worse: |
| 20 |
it opens the PDF file using mandatory locking, making it absolutely |
| 21 |
impossible to recompile the document while it is still open in the |
| 22 |
Reader. |
| 23 |
|
| 24 |
Common practice using Acrobat Reader for viewing PDF's generated from |
| 25 |
pdf\TeX{} is therefore to cycle through these actions, either from |
| 26 |
the command line or from a script: |
| 27 |
|
| 28 |
\startitemize[n] |
| 29 |
\item edit the \TeX{} source |
| 30 |
\item compile to PDF |
| 31 |
\item view with Acrobat Reader |
| 32 |
\item close Acrobat Reader |
| 33 |
\stopitemize |
| 34 |
It follows that the Reader has to make a complete restart for each |
| 35 |
cycle, which is a slow operation. The alternative would be to run the |
| 36 |
Reader in the background and ask users to, after steps 1.~and 2., |
| 37 |
manually close and reopen the document. That is not user-friendly, of |
| 38 |
course, and that's where \type{pdfopen} and \type{pdfclose}, described |
| 39 |
in this article, will be useful. |
| 40 |
|
| 41 |
Because the problem was much more severe under Windows, a few years ago |
| 42 |
Fabrice Popineau has written two small programs that use DDE calls to |
| 43 |
control the Reader from an external script or batchfile: |
| 44 |
\startitemize |
| 45 |
\item \type{pdfclose} to make the Reader close the file before the |
| 46 |
compilation starts |
| 47 |
\item \type{pdfopen} to re-open the file afterwards. |
| 48 |
\stopitemize |
| 49 |
The Linux X11 versions are command||line compatible with Fabrice's |
| 50 |
originals, but they do not function completely identically. |
| 51 |
|
| 52 |
\starttyping |
| 53 |
pdfclose --file <pdf file> |
| 54 |
\stoptyping |
| 55 |
This will close an X window with the name \type{<pdf file>} (for |
| 56 |
Acrobat Reader~5) or the name \type{Adobe Reader - <pdf file>} |
| 57 |
(for Adobe Reader~7). |
| 58 |
|
| 59 |
\starttyping |
| 60 |
pdfclose --all |
| 61 |
\stoptyping |
| 62 |
The Linux \type{pdfclose} command ignores the \type{-}\type{-all} |
| 63 |
command||line switch. The Windows version will close {\it only\/} the |
| 64 |
files that were opened through \type{pdfopen} when \type{-}\type{-all} is |
| 65 |
given, and this cannot easily be done under X. Ignoring the options |
| 66 |
seems wiser than unconditionally closing all open PDF documents. |
| 67 |
|
| 68 |
\starttyping |
| 69 |
pdfopen |
| 70 |
\stoptyping |
| 71 |
This command||line sends a ``go to previous document'' to an already |
| 72 |
existing, but empty, Adobe Reader window. There are perhaps some |
| 73 |
situations where this possibility might come in handy. |
| 74 |
|
| 75 |
|
| 76 |
\starttyping |
| 77 |
pdfopen --file <pdf file> [--page <pagenumber>] |
| 78 |
\stoptyping |
| 79 |
The Linux version silently ignores a given |
| 80 |
\type{-}\type{-page} option, because its behaviour would be near||impossible to |
| 81 |
predict. The program also reacts a bit differently to the |
| 82 |
\type{-}\type{-file} option: if the file is already open in the |
| 83 |
Reader, it will close and re||open the document. |
| 84 |
|
| 85 |
Normally, this is the command you want to use under Linux, because it |
| 86 |
immediately re||opesn the PDF file you have given as an argument in |
| 87 |
the Reader, using the same page \& view settings. The result is {\it |
| 88 |
almost\/} as if there was a refresh command in the Reader. {\it |
| 89 |
Almost\/}, because it only works if just this document is open for |
| 90 |
viewing, not if there are more files opened. |
| 91 |
|
| 92 |
\blank |
| 93 |
I've tested my programs with Acrobat Reader 5.0.10 under Mandrake |
| 94 |
Linux 10.1 using X.org 6.8.2, but the code is reasonably generic and |
| 95 |
should work out of the box using most X11R6 implementations. |
| 96 |
Version 0.5 compiles under X11R5 as well. |
| 97 |
|
| 98 |
Adobe Reader 7.0 is OK as long as you keep your PDF files maximized |
| 99 |
within the main Adobe Reader window (the PDF document's name has to |
| 100 |
appear in the window title). Also, you probably want to set the |
| 101 |
preference {\it Reopen documents to last viewed page\/} to ``All |
| 102 |
files''. You can find this setting in the {\it Startup\/} page of the |
| 103 |
preferences screen. |
| 104 |
|
| 105 |
\medskip |
| 106 |
\noindent |
| 107 |
Source and binaries of the programs can be downloaded from |
| 108 |
\hyphenatedurl{CTAN://support/xpdfopen/} or : |
| 109 |
\hyphenatedurl{http://tex.aanhet.net/pdfopen} |
| 110 |
|
| 111 |
\stoptext |