[NTG-pdftex] Spurious /NewWindow false

Hartmut Henkel hartmut_henkel@gmx.de
Sat, 28 Jun 2003 00:08:06 +0200 (CEST)


Hi pdftex fans,

there is some minor loose end within pdftex: Using teTeX-2.0.2 pdflatex
(pdfTeX, Version 3.14159-1.10b (Web2C 7.4.5)), I tried to do a
goto-remote to a page by its number in another document. As this is not
possible with \hyperref AFAIK (there was some c.t.t. thread in 2002), I
tried the following macro (not using the user{} action):

\def\pdfhref#1#2#3{%
  \leavevmode\pdfstartlink
    attr{/Border[0 0 1]/H/I/C[0 .5 .5]}%
    goto file{#1}page#2{/Fit}#3%
  \pdfendlink
}

Example: \pdfhref{foo.pdf}{8}{Click here!}. This produced lines in the
PDF file like:

/A << /F (foo.pdf) /S /GoToR /D [1 /Fit] >>

But some lines looked as follows (!):

/A << /F (Pay.pdf) /NewWindow false /S /GoToR /D [2 /Fit] >>

File pdftex.ch shows, that /NewWindow is produced when
pdf_action_new_window(p) > 0. Printing out the pdf_action_new_window(p)
values in the cases, where /NewWindow was in the PDF file, brought crazy
large numbers, as with an uninitialized variable; here is why: Function
scan_action in pdftex.ch has a return statement at the end of the "page"
case, so the code for setting the pdf_action_new_window(p) variable at
the end of the function is not reached. In the goto-name and goto-num
case, pdf_action_new_window(p) is initialized. So the problem of
spurious /NewWindow happens only in the goto-page case.

Now I tried the newwindow/nonewwindow tag, but got an error, which
should not be there: "`newwindow'/`nonewwindow' must be used with `goto'
and `file' option". See end of function scan_action. Reason is, that in
the goto-page case the pdf_action_type(p) changes from pdf_action_goto
into pdf_action_page, but this is not checked by the if-statement at the
end of the function.

It seems to work now (no spurious /NewWindow, (no)newwindow usable also
in page case), with the small patch below. The problem is rather minor,
as \pdfstartlink...\pdfendlink seems to be used in most cases (e. g. by
hyperref.sty) through the more versatile user{} action. Anyway... Here
is the patch to pdftex.ch (hope it doen't break anything):

------------------------------------------------------------------------
--- pdftex.ch.orig	Fri Jun 27 23:16:00 2003
+++ pdftex.ch	Fri Jun 27 23:50:03 2003
@@ -6858,7 +6858,6 @@
         pdf_action_named_id(p) := 0;
         call_func(scan_toks(false, true));
         pdf_action_page_tokens(p) := def_ref;
-        return;
     end
     else if scan_keyword("name") then begin
         call_func(scan_toks(false, true));
@@ -6885,10 +6884,11 @@
     else
         pdf_action_new_window(p) := 0;
     if (pdf_action_new_window(p) > 0) and
-       ((pdf_action_type(p) <> pdf_action_goto) or
-        (pdf_action_file(p) = null)) then
-           pdf_error("ext1",
-               "`newwindow'/`nonewwindow' must be used with `goto' and `file' option");
+        (((pdf_action_type(p) <> pdf_action_goto) and
+          (pdf_action_type(p) <> pdf_action_page)) or
+         (pdf_action_file(p) = null)) then
+            pdf_error("ext1",
+                "`newwindow'/`nonewwindow' must be used with `goto' and `file' option");
 end;

 procedure new_annot_whatsit(w, s: small_number); {create a new whatsit node for
------------------------------------------------------------------------

Here is a small update for file pdftex-syntax.txt, showing that the
(no)newwindow stuff is allowed only in remote-goto's:

------------------------------------------------------------------------
--- pdftex-syntax.txt.orig	Thu Jan 16 15:37:00 2003
+++ pdftex-syntax.txt	Fri Jun 27 23:39:27 2003
@@ -94,19 +94,19 @@
 <resources spec> --> resources <general text>
 <image attr spec> --> [<rule spec>] [<attr spec>] [<page spec>] [<pdf box spec>]
 <outline spec> --> <action spec> [count <number>] <general text>
-<action spec> --> <select action spec> [<newwindow spec>]
-<newwindow spec> --> newwindow
-                   | nonewwindow
+<action spec> --> <select action spec>
 <select action spec> --> user <user-action spec>
                        | goto <goto-action spec>
                        | thread <thread-action spec>
 <user-action spec> --> user <general text>
 <goto-action spec> --> <numid>
-                     | [<file spec>] <nameid>
-                     | [<file spec>] [<page spec>] <general text>
+                     | [<file spec>] <nameid> [<newwindow spec>]
+                     | [<file spec>] [<page spec>] <general text> [<newwindow spec>]
 <pdf box spec> --> artbox|trimbox|bleedbox|cropbox|mediabox
 <numid> --> num <number>
 <nameid> --> name <general text>
+<newwindow spec> --> newwindow
+                   | nonewwindow
 <thread-action spec> --> [<file spec>] <numid>
                        | [<file spec>] <nameid>
 <dest spec> --> <numid> <dest type>
------------------------------------------------------------------------

Greetings Hartmut


------------------------------------------------------------------------
Hartmut Henkel, Oftersheim, Germany
------------------------------------------------------------------------