summaryrefslogtreecommitdiff
path: root/Build/source/utils/pdfopen/xpdfopen.tex
blob: d0348f622daed6df8b6fcf6eddce0328e864c7b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111

\setupoutput[pdftex]

\starttext


\chapter{Controlling Acrobat Reader under X11}


\centerline{Taco Hoekwater, taco(at)aanhet.net}

\blank[3*line]

Most people who use the Acrobat Reader to preview PDF files
generated from \TeX\ documents will know that it is a hassle to
deal with documents that need to be compiled while being viewed.

The Linux version of Adobe's program simply does not notice that the
PDF file has changed, and the Microsoft Windows version is even worse:
it opens the PDF file using mandatory locking, making it absolutely
impossible to recompile the document while it is still open in the
Reader.

Common practice using Acrobat Reader for viewing PDF's generated from
pdf\TeX{} is therefore to cycle through these actions, either from
the command line or from a script:

\startitemize[n]
\item edit the \TeX{} source
\item compile to PDF
\item view with Acrobat Reader
\item close Acrobat Reader
\stopitemize
It follows that the Reader has to make a complete restart for each
cycle, which is a slow operation. The alternative would be to run the
Reader in the background and ask users to, after steps 1.~and 2.,
manually close and reopen the document. That is not user-friendly, of
course, and that's where \type{pdfopen} and \type{pdfclose}, described
in this article, will be useful.

Because the problem was much more severe under Windows, a few years ago
Fabrice Popineau has written two small programs that use DDE calls to
control the Reader from an external script or batchfile:
\startitemize
\item \type{pdfclose} to make the Reader close the file before the
compilation starts
\item \type{pdfopen} to re-open the file afterwards.
\stopitemize
The Linux X11 versions are command||line compatible with Fabrice's
originals, but they do not function completely identically.

\starttyping
pdfclose --file <pdf file>
\stoptyping
This will close an X window with the name \type{<pdf file>} (for
Acrobat Reader~5) or the name \type{Adobe Reader - <pdf file>}
(for Adobe Reader~7).

\starttyping
pdfclose --all
\stoptyping
The Linux \type{pdfclose} command ignores the \type{-}\type{-all}
command||line switch. The Windows version will close {\it only\/} the
files that were opened through \type{pdfopen} when \type{-}\type{-all} is
given, and this cannot easily be done under X. Ignoring the options
seems wiser than unconditionally closing all open PDF documents.

\starttyping
pdfopen
\stoptyping
This command||line sends a ``go to previous document'' to an already
existing, but empty, Adobe Reader window.  There are perhaps some
situations where this possibility might come in handy.


\starttyping
pdfopen --file <pdf file> [--page <pagenumber>]
\stoptyping
The Linux version silently ignores a given
\type{-}\type{-page} option, because its behaviour would be near||impossible to
predict. The program also reacts a bit differently to the
\type{-}\type{-file} option: if the file is already open in the
Reader, it will close and re||open the document. 

Normally, this is the command you want to use under Linux, because it
immediately re||opesn the PDF file you have given as an argument in
the Reader, using the same page \& view settings. The result is {\it
almost\/} as if there was a refresh command in the Reader. {\it
Almost\/}, because it only works if just this document is open for
viewing, not if there are more files opened.

\blank
I've tested my programs with Acrobat Reader 5.0.10 under Mandrake
Linux 10.1 using X.org 6.8.2, but the code is reasonably generic and
should work out of the box using most X11R6 implementations. 
Version 0.5 compiles under X11R5 as well.

Adobe Reader 7.0 is OK as long as you keep your PDF files maximized
within the main Adobe Reader window (the PDF document's name has to
appear in the window title). Also, you probably want to set the
preference {\it Reopen documents to last viewed page\/} to ``All
files''. You can find this setting in the {\it Startup\/} page of the
preferences screen.

\medskip
\noindent
Source and binaries of the programs can be downloaded from 
\hyphenatedurl{CTAN://support/xpdfopen/} or :
\hyphenatedurl{http://tex.aanhet.net/pdfopen}

\stoptext