texlive[58203] branches/branch2020.0/Master/texmf-dist: newpax

commits+karl at tug.org commits+karl at tug.org
Sun Mar 7 23:06:31 CET 2021


Revision: 58203
          http://tug.org/svn/texlive?view=revision&revision=58203
Author:   karl
Date:     2021-03-07 23:06:31 +0100 (Sun, 07 Mar 2021)
Log Message:
-----------
newpax (7mar21) (branch)

Added Paths:
-----------
    branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/
    branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/README.md
    branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-extract-newpax.tex
    branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-extract-pax.tex
    branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-input1.pdf
    branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-input1.tex
    branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-input2.pdf
    branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-input2.tex
    branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-use-newpax.pdf
    branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-use-newpax.tex
    branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-use-pax.pdf
    branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-use-pax.tex
    branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/newpax.pdf
    branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/newpax.tex
    branches/branch2020.0/Master/texmf-dist/source/latex/newpax/
    branches/branch2020.0/Master/texmf-dist/source/latex/newpax/newpax.dtx
    branches/branch2020.0/Master/texmf-dist/source/latex/newpax/newpax.ins
    branches/branch2020.0/Master/texmf-dist/tex/latex/newpax/
    branches/branch2020.0/Master/texmf-dist/tex/latex/newpax/newpax.lua
    branches/branch2020.0/Master/texmf-dist/tex/latex/newpax/newpax.sty

Removed Paths:
-------------
    branches/branch2020.0/Master/texmf-dist/doc/lualatex/newpax/
    branches/branch2020.0/Master/texmf-dist/source/lualatex/newpax/
    branches/branch2020.0/Master/texmf-dist/tex/lualatex/newpax/

Added: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/README.md
===================================================================
--- branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/README.md	                        (rev 0)
+++ branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/README.md	2021-03-07 22:06:31 UTC (rev 58203)
@@ -0,0 +1,26 @@
+#newpax — A package to reinsert links in PDF included as graphics
+
+This package allows to insert PDF in a document while preserving
+internal and external links. With lualatex it works in the document
+directly, other engines require to run a compilaton with lualatex or to call
+a lua script first.
+
+The package is based on and uses code from [pax](https://ctan.org/pkg/pax) by Heiko Oberdiek.
+
+Packageversion: 0.51 
+Packagedate: 2021-02-26
+Author: Ulrike Fischer
+
+## License
+The newpax package may be modified and distributed under the terms and conditions of the 
+[LaTeX Project Public License](https://www.latex-project.org/lppl/), version 1.3c or greater.
+
+## Installation
+
+Use the package manager of your texsystem or
+unpack the dtx and put the sty and the lua into tex\latex\newpax.
+
+
+## Issues, comments, etc
+
+https://github.com/u-fischer/newpax


Property changes on: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/README.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-extract-newpax.tex
===================================================================
--- branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-extract-newpax.tex	                        (rev 0)
+++ branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-extract-newpax.tex	2021-03-07 22:06:31 UTC (rev 58203)
@@ -0,0 +1,11 @@
+\documentclass{article}
+% load the lua code
+\directlua{require("newpax")}
+% write .newpax files for newpax.sty
+\directlua
+  {
+    newpax.writenewpax("doc-input1")
+    newpax.writenewpax("doc-input2")
+  }
+\begin{document}
+\end{document} 
\ No newline at end of file


Property changes on: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-extract-newpax.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-extract-pax.tex
===================================================================
--- branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-extract-pax.tex	                        (rev 0)
+++ branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-extract-pax.tex	2021-03-07 22:06:31 UTC (rev 58203)
@@ -0,0 +1,12 @@
+\documentclass{article}
+% load the lua code
+\directlua{require("newpax")}
+
+% and/or write .pax files for pax.sty
+\directlua
+  {
+    newpax.writepax("doc-input")
+    newpax.writepax("doc-input2")
+  }
+\begin{document}
+\end{document} 
\ No newline at end of file


Property changes on: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-extract-pax.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-input1.pdf
===================================================================
(Binary files differ)

Index: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-input1.pdf
===================================================================
--- branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-input1.pdf	2021-03-07 22:06:14 UTC (rev 58202)
+++ branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-input1.pdf	2021-03-07 22:06:31 UTC (rev 58203)

Property changes on: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-input1.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-input1.tex
===================================================================
--- branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-input1.tex	                        (rev 0)
+++ branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-input1.tex	2021-03-07 22:06:31 UTC (rev 58203)
@@ -0,0 +1,51 @@
+% !Mode:: "TeX:UTF-8:Main"
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{uncompress}
+\documentclass{article}
+\usepackage{hyperref}
+
+\hypersetup{pdfborderstyle={/S/U/W 1},
+   pdfauthor=Author,pdftitle=title,pdfcreator=creator}
+
+\ExplSyntaxOn
+\pdfmanagement_add:nnn {Page} {TrimBox}{[0~0~300~350]}
+\pdfmanagement_add:nnn {Page} {BleedBox}{[0~0~300~350]}
+\ExplSyntaxOff
+
+\usepackage{kantlipsum}
+\begin{document}
+\ExplSyntaxOn
+x\pdfannot_link_goto_begin:nw {section.2}
+    link text
+ \pdfannot_link_goto_end:
+\ExplSyntaxOff
+
+\ref{sec}
+\url{https://www.latex-project.org}
+
+\href[ismap=true]{https://www.latex-project.org}{\kant*[1]}
+
+\href{file:/c/texlive/2020/texmf-dist/doc/latex/base/doc.pdf#chapter.1}{pdf}
+
+\section{abc}\label{sec}
+
+\section{abc}\label{sec2}
+
+\section{abc}\label{sec3}
+
+\href{example-image.pdf}{file}
+
+%\Acrobatmenu{LastPage}{Go to last page}
+\newpage
+
+\url{https://www.latex-project.org}
+
+
+\ref{sec} \quad  \ref{sec2} \quad \ref{sec3}
+\newpage
+
+\Acrobatmenu{FirstPage}{Go to first page}
+\newpage
+
+blub
+\end{document} 
\ No newline at end of file


Property changes on: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-input1.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-input2.pdf
===================================================================
(Binary files differ)

Index: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-input2.pdf
===================================================================
--- branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-input2.pdf	2021-03-07 22:06:14 UTC (rev 58202)
+++ branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-input2.pdf	2021-03-07 22:06:31 UTC (rev 58203)

Property changes on: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-input2.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-input2.tex
===================================================================
--- branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-input2.tex	                        (rev 0)
+++ branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-input2.tex	2021-03-07 22:06:31 UTC (rev 58203)
@@ -0,0 +1,46 @@
+% !Mode:: "TeX:UTF-8:Main"
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{uncompress}
+\documentclass{article}
+\usepackage{hyperref}
+
+\hypersetup{pdfborderstyle={/S/U/W 1},
+   pdfauthor=Author,pdftitle=title,pdfcreator=creator}
+
+\ExplSyntaxOn
+\pdfmanagement_add:nnn {Page} {TrimBox}{[0~0~300~350]}
+\pdfmanagement_add:nnn {Page} {BleedBox}{[0~0~300~350]}
+\ExplSyntaxOff
+
+\usepackage{kantlipsum}
+\begin{document}
+
+\ref{sec}
+\url{https://www.latex-project.org}
+
+\href[ismap=true]{https://www.latex-project.org}{\kant*[1]}
+
+\href{file:/c/texlive/2020/texmf-dist/doc/latex/base/doc.pdf#chapter.1}{pdf}
+
+\section{abc}\label{sec}
+
+\section{abc}\label{sec2}
+
+\section{abc}\label{sec3}
+
+\href{example-image.pdf}{file}
+
+%\Acrobatmenu{LastPage}{Go to last page}
+\newpage
+
+\url{https://www.latex-project.org}
+
+
+\ref{sec} \quad  \ref{sec2} \quad \ref{sec3}
+\newpage
+
+\Acrobatmenu{FirstPage}{Go to first page}
+\newpage
+
+blub
+\end{document} 
\ No newline at end of file


Property changes on: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-input2.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-use-newpax.pdf
===================================================================
(Binary files differ)

Index: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-use-newpax.pdf
===================================================================
--- branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-use-newpax.pdf	2021-03-07 22:06:14 UTC (rev 58202)
+++ branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-use-newpax.pdf	2021-03-07 22:06:31 UTC (rev 58203)

Property changes on: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-use-newpax.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-use-newpax.tex
===================================================================
--- branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-use-newpax.tex	                        (rev 0)
+++ branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-use-newpax.tex	2021-03-07 22:06:31 UTC (rev 58203)
@@ -0,0 +1,35 @@
+% !Mode:: "TeX:UTF-8:Main"
+
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{uncompress}
+\documentclass{article}
+
+\usepackage{pdfpages,xcolor}
+
+\usepackage{hyperref}
+\hypersetup{linkbordercolor=blue}
+
+\usepackage{newpax}
+
+%use the link border color and style of the imported pdf
+%and not hyperref colors
+\newpaxsetup{usefileattributes=true}
+
+\begin{document}
+
+\includegraphics[scale=0.5,trim=4cm 15cm 8cm 3cm,clip,page=1]{doc-input1}
+\includegraphics[scale=0.5,trim=5cm 15cm 8cm 3cm,clip,page=2]{doc-input1}
+
+%set a unique suffix if the pdf is imported twice
+\newpaxsetup{destsuffix=B}
+\includegraphics[scale=0.5,trim=4cm 15cm 8cm 3cm,clip,page=1]{doc-input1}
+\includegraphics[scale=0.5,trim=5cm 15cm 8cm 3cm,clip,page=2]{doc-input1}
+
+% suppress the adding of annotations
+\newpaxsetup{addannots=false}
+\includegraphics[scale=0.5,trim=4cm 15cm 8cm 3cm,clip,page=1]{doc-input1}
+
+%reactivate, don't use file attributes
+\newpaxsetup{addannots=true,usefileattributes=false}
+\includepdf[pages=-]{doc-input2}
+\end{document}


Property changes on: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-use-newpax.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-use-pax.pdf
===================================================================
(Binary files differ)

Index: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-use-pax.pdf
===================================================================
--- branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-use-pax.pdf	2021-03-07 22:06:14 UTC (rev 58202)
+++ branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-use-pax.pdf	2021-03-07 22:06:31 UTC (rev 58203)

Property changes on: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-use-pax.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-use-pax.tex
===================================================================
--- branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-use-pax.tex	                        (rev 0)
+++ branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-use-pax.tex	2021-03-07 22:06:31 UTC (rev 58203)
@@ -0,0 +1,25 @@
+% !Mode:: "TeX:UTF-8:Main"
+\documentclass{article}
+\usepackage{ifluatex,etoolbox}
+\usepackage{pdfpages}
+%pax needs this to run with lualatex
+\ifluatex
+\usepackage{pdftexcmds}
+\makeatletter
+\let\pdfstrcmp\pdf at strcmp
+\let\pdfescapename\pdf at escapename
+\makeatother
+\usepackage{luatex85}
+\fi
+%load pax
+\usepackage{pax}
+%correct a bug in pax affecting clipping
+\makeatletter
+\patchcmd\PAX at pdf@annot{\PAX at pagellx}{\PAX at page@llx}{}{\fail}
+\makeatother
+\begin{document}
+\includegraphics[scale=0.5,trim=5cm 15cm 8cm 3cm,clip,page=2]{doc-input1}
+\includegraphics[scale=0.5,trim=5cm 15cm 8cm 3cm,clip,page=1]{doc-input1}
+
+\includepdf[pages=-]{doc-input2}
+\end{document}


Property changes on: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/doc-use-pax.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/newpax.pdf
===================================================================
(Binary files differ)

Index: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/newpax.pdf
===================================================================
--- branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/newpax.pdf	2021-03-07 22:06:14 UTC (rev 58202)
+++ branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/newpax.pdf	2021-03-07 22:06:31 UTC (rev 58203)

Property changes on: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/newpax.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/newpax.tex
===================================================================
--- branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/newpax.tex	                        (rev 0)
+++ branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/newpax.tex	2021-03-07 22:06:31 UTC (rev 58203)
@@ -0,0 +1,219 @@
+% !Mode:: "TeX:UTF-8:Main"
+\makeatletter
+\def\UlrikeFischer at package@version{0.51}
+\def\UlrikeFischer at package@date{2021-03-07}
+\makeatother
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{pdfversion=1.7,lang=en-UK, uncompress}
+
+\documentclass[DIV=12,parskip=half-,bibliography=totoc]{scrartcl}
+\usepackage{scrlayer-scrpage}
+\usepackage{fontspec}
+\setmainfont{Heuristica}
+\usepackage{unicode-math}
+\usepackage[english]{babel}
+\usepackage[autostyle]{csquotes}
+\usepackage{microtype}
+\usepackage{listings}
+\def\lstlanguagefiles
+    {lstlang0.sty,lstlang1.sty,lstlang2.sty,lstlang3.sty}
+
+\lstset{basicstyle=\ttfamily, columns=fullflexible,language=[LaTeX]TeX,
+        escapechar=*,
+        commentstyle=\color{green!50!black}\bfseries}
+\usepackage[pdfdisplaydoctitle=true,hyperfootnotes=false]{hyperref}
+\hypersetup{pdftitle=The newpax package,pdfauthor=Ulrike Fischer}
+\usepackage{ydoc-desc}
+
+\usepackage{newpax}
+\directlua{require("newpax")}
+% write pax and .newpax files
+\directlua
+  {
+    newpax.writenewpax("doc-input1")
+    newpax.writenewpax("doc-input2")
+    newpax.writepax("doc-input1")
+    newpax.writepax("doc-input2")
+  }
+\newpaxsetup{usefileattributes}
+
+\title{The \pkg{newpax} package, v\csname UlrikeFischer at package@version\endcsname}
+\subtitle{Reinserting annotations from included pdf file}
+\date{\csname UlrikeFischer at package@date\endcsname}
+\author{Ulrike Fischer\thanks{fischer at troubleshooting-tex.de}}
+
+\begin{document}
+\maketitle
+
+\section{Introduction}
+
+Links in a PDF are created with annotation objects. Such an object is not connected to the content
+or text, but simply describes an (rectangular) area on the page and defines an action if the
+cursor is in the area. The coordinates of the area are given in absolute page coordinates.
+The action of such an annotation can be an external URL, but also an internal destination.
+Such destination are objects describing a page and some instructions how to display the page---again using absolute coordinates.
+
+When a PDF is included in another PDF---may it be with \cs{includegraphics} or with \cs{includepdf}--the annotation coordinates no longer make sense as they don't refer to the receiving page (and often the action of an annotation doesn't make sense either), so all TeX-engines and backends strip them away when including a PDF: the net effect is that external and internal links are lost.
+
+The \pkg{pax} package from Heiko Oberdiek offers a solution for this problem: it extracts all the annotations
+and destinations of the included PDF in a text file, does some clever recalculations of their coordinates and reinserts them.
+The package works basically fine but has a few drawbacks: To collect the annotation one has to run an external
+java program which relies on an now outdated library, and it works only with pdf\LaTeX{}.
+
+The \pkg{newpax} tries to address these problems. It offers a lua script to extract the annotations.
+The script can be used with lua(la)tex  and no external tools are needed. The annotations can
+then be reinserted either with the \pkg{pax.sty} or with the new \pkg{newpax.sty} whose code based in large parts on the \pkg{pax} package: it uses its data structure and the original code to calculate the coordinates (with a few minor bug corrections), but the pdf\LaTeX{} primitives have been replaced by commands from the new \LaTeX{} PDF management in \pkg{pdfmanagement-testphase} so it should works with all major engines and backends (with the exception of dvips).
+
+
+\section{Quick use instructions}
+
+\subsection{Step 1: extract and collect the annotations}
+
+The lua script offers a function which take as argument the name of a PDF (without the extension).
+The function can be used in some lua scripts but also in a document which then must be compiled
+with lualatex.
+
+\lstinputlisting[caption=doc-extract-newpax.tex]{doc-extract-newpax.tex}
+
+Running this document will create the files \file{doc-input1.newpax} and \file{doc-input2.newpax}.
+
+To find the graphics \texttt{kpathsea} is used. This means that graphics in texmf trees will work and
+you can also use paths to directories, but settings in \cs{graphicspath} are ignored. The newpax
+file is currently written into the current directory, which means that graphics with the same name
+in different locations won't work easily (with lualatex you could create the newpax file in the document
+just before it is needed). Later versions of the package will probably add some options for this case,
+but for now use at best distinct file names.
+
+
+\subsection{Step 2: Using the \texttt{.newpax}-file with \texorpdfstring{\pkg{newpax}}{newpax}}
+
+The package \pkg{newpax} is based on the package \pkg{pax} but extends it in various way.
+It is still an experimental package, and it requires the new \LaTeX{} PDF management
+code in \pkg{pdfmanagement-testphase} package. This new code is---as the name implies---currently in the testphase and \emph{not} compatible with every package!
+
+The following listing shows how to use \pkg{newpax}.
+
+\begin{itemize}
+\item It should work with pdflatex, lualatex and xelatex. The latex/dvips route fails as this can't include PDF anyway.
+\item Some provision have been added to allow multiple inclusion of the same PDF, but if you insert different sets of pages from a PDF some destinations can still be missing. So better avoid it.
+\item You can choose for every file if border color and styles of links are taken from the source PDF or from the hyperref settings. But you can't adjust or change colored links.
+\item You can add additional settings to the annotations, for example an \texttt{/F} flag, with
+
+\begin{lstlisting}
+\ExplSyntaxOn
+\pdfannot_dict_put:nnn {link/URI}{F}{4}
+\ExplSyntaxOff
+\end{lstlisting}
+
+\end{itemize}
+
+\lstinputlisting[firstline=2,caption=doc-use-newpax.tex]{doc-use-newpax.tex}
+
+\subsection{Combining the steps}
+
+When using lualatex both step can be simply in the same document.
+With other engines you can use \pkg{ifluatex}.
+
+
+
+\section{Setup options}
+
+\DescribeMacro\newpaxsetup{key-val option list}
+
+This command allows to change the behaviour inclusion. It knows the following keys:
+
+\begin{description}
+  \item[\PrintKeyName{usefileattributes}] This is a boolean key. If set to true, the reinserted annotations will use the linkborder settings (color and style) of the included file, if set to false, the settings of the receiving PDF will take precendence.
+
+  \item[\PrintKeyName{destsuffix}] This allows to add a suffix to the destination names. This is needed if a file with destinations
+  is included more than once, to avoid to get multiple destinations.
+
+ \item[\PrintKeyName{addannots}] This is a boolean key. It allows to switch on and off the reinserting of the annotations. When set to false  it also suppress warnings in the log if the \file{.newpax} file is not found.
+     It is recommended to set it to false for graphics which don't have links.
+
+\end{description}
+
+
+\section{More Background}
+
+Clickable links in a PDF are one example of an annotation. Annotations are areas on a page which are associated with an action. A typical annotation object could look like this in the PDF:
+
+\begin{lstlisting}
+15 0 obj
+<<
+/Type /Annot
+/Subtype/Link
+/Rect [147.716 654.025 301.887 665.15]
+/Border[0 0 1]/BS<</S/U/W 1>>/H/I/C[0 1 1]
+/A<</Type/Action/S/URI/URI(https://www.latex-project.org)>>
+>>
+endobj
+\end{lstlisting}
+This is an object of type \texttt{Annot} and subtype \texttt{Link}.
+The \texttt{/Rect} value describes the rectangle of this annotation. The coordinates are absolute coordinates related to the current page. It is important to understand that an annotation is not connected to some page content but only to a location!
+The \texttt{/Border} setting and the other values in this line describe the look and color of annotation. The \texttt{/A} value contains the action, in this case it is an url to an external website.
+
+
+To \enquote{reactivate} the annotations of an included pdf one has to do a number of tasks.
+\begin{itemize}
+\item One must \emph{retrieve and store} the annotations of the included pdf. For links to external url's this requires to find only one object like the one shown above. But e.g. internal links point to destination objects and these must be found too.
+\item One must \emph{recalculate} the rectangle coordinates to fit to the coordinate system of the target page: as the included pdf can be placed at various positions, scaled, rotated and even clipped this is not an easy task. Destinations have rectangles too that must be recalculated.
+\item  One must  \emph{reinsert} the annotation and related objects. This has to take into account that a pdf is perhaps not included completely, a link shouldn't point to a missing page or a clipped annotation. It also has to take into account that a pdf is perhaps inserted more than once or in steps.
+\end{itemize}
+
+\subsection{Retrieving and storing annotations}
+
+Theoretically one can do it manually: Uncompress the PDF (or when using \LaTeX, create directly an uncompressed one), open it in an editor and copy and paste all needed objects. Practically one naturally want some tool.
+
+The \pkg{pax} package from Heiko Oberdiek consists of a perl script and a java-jar file \texttt{PDFAnnotExtractor} which can extract the necessary objects. It writes the information to a file with the extension \texttt{pax}.
+When it has been successfully installed it works quite fine. Problems with this approach are
+\begin{itemize}
+\item \texttt{PDFAnnotExtractor} requires an external, old version of the java library of PDFbox which must be installed manually;
+\item it requires a java installation and
+\item it is not extensible.
+\end{itemize}
+
+The \pkg{newpax} package comes with a lua-file. It uses the \texttt{pdfe} library embedded in luatex to extract the annotations and other needed information. \pkg{newpax} writes the information to a file with the extension \texttt{pax} or \texttt{newpax}. The content of the files is (nearly) identical to the content of the \file{pax}-file written by \texttt{PDFAnnotExtractor}. The lua code was written by looking at example outputs from \texttt{PDFAnnotExtractor} and reproducing it in lua. The ordering of some elements is a bit different and some strings are output in a different way but for the examples I used the resulting \texttt{pax}-files can be used together with the original \texttt{pax.sty}. But due to the fact that the code was written without real spec simply by looking at examples, it is quite probably that the lua code is not yet handling all objects or options that \texttt{PDFAnnotExtractor} outputs.  But the code can rather easily be extended when the needs arises.
+
+The code also doesn't handle structure elements, neither at the export nor at the import. I have yet no real idea what would be sensible here (and I'm quite sure that \texttt{PDFAnnotExtractor}  doesn't handle this either.)
+
+
+\section{Importing annotations}
+
+The \pkg{pax} package from Heiko Oberdiek does the hard work to recalculate the annotation rectangles and to decide which annotation and which destination should be reinserted. It also patches the \cs{includegraphics} command to automate this.
+\pkg{newpax} reuses the core commands of \pkg{pax}. It only adds a number of switches and changes primitive to support more engines and backends.
+
+
+
+\section{Example input}
+
+\fbox{\includegraphics[scale=0.5,trim=4cm 15cm 8cm 3cm,clip,page=1]{doc-input1}}
+\fbox{\includegraphics[scale=0.5,trim=5cm 15cm 8cm 3cm,clip,page=2]{doc-input1}}
+
+Check also the output of the listing above, \file{doc-use-newpax.pdf}.
+
+\section{Support for the \texorpdfstring{\pkg{pax}}{pax} package}
+
+\subsection{Step 1: Extracting the annotations}
+The lua script is also able to write \texttt{pax} files for the \pkg{pax} package (and so can be used to replace the java application).
+
+For this extract the annotations like this:
+
+\lstinputlisting[caption=doc-extract-pax.tex]{doc-extract-pax.tex}
+
+\subsection{Step 2: Using the \texttt{.pax}-file with \pkg{pax.sty}}
+
+Ensure that the \texttt{.pax} file created in step 1 can be found by your main document. You can then insert your PDF files together with their annotations like in the following listing.
+
+\begin{itemize}
+\item This works with pdflatex and lualatex. lualatex needs the extra code demonstrated in the document.
+\item It needs two or three compilations until every reference is correct.
+\item There is a small typo in \pkg{pax.sty} which affects clipping, the patch shown in the listing correct this.
+\item Don't include PDFs with destinations twice as this will lead to duplicate destinations and pdflatex will complain.
+\item If annotations should not be reinserted remove the \texttt{.pax}-file.
+\item If \pkg{hyperref} is loaded you can change the color and style of link borders with hyperref options.
+\end{itemize}
+
+\lstinputlisting[firstline=2,caption=doc-use-pax.tex]{doc-use-pax.tex}
+
+\end{document}


Property changes on: branches/branch2020.0/Master/texmf-dist/doc/latex/newpax/newpax.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: branches/branch2020.0/Master/texmf-dist/source/latex/newpax/newpax.dtx
===================================================================
--- branches/branch2020.0/Master/texmf-dist/source/latex/newpax/newpax.dtx	                        (rev 0)
+++ branches/branch2020.0/Master/texmf-dist/source/latex/newpax/newpax.dtx	2021-03-07 22:06:31 UTC (rev 58203)
@@ -0,0 +1,1217 @@
+% \iffalse meta-comment
+%
+% File: newpax.dtx
+% Copyright 2006-2008, 2011, 2012 Heiko Oberdiek (original pax.sty)
+% Copyright (C) 2021 Ulrike Fischer
+%
+% It may be distributed and/or modified under the conditions of the
+% LaTeX Project Public License (LPPL), either version 1.3c of this
+% license or (at your option) any later version.  The latest version
+% of this license is in the file
+%
+%    https://www.latex-project.org/lppl.txt
+%
+% This file is part of the "newpax bundle" (The Work in LPPL)
+% and all files in that bundle must be distributed together.
+%
+% -----------------------------------------------------------------------
+%
+% The development version of the bundle can be found at
+%
+%    https://github.com/u-fischer/newpax
+%
+% for those people who are interested.
+%
+% \fi
+%
+%    \begin{macrocode}
+%<*package>
+%<@@=newpax>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{newpax}%
+  [2021-03-07 v0.51 Annotation support for PDF graphics based on pax.sty adapted by (UF)]%
+\ExplSyntaxOn
+\bool_if:nF
+  {
+    \cs_if_exist_p:N \pdfmanagement_if_active_p:
+  }
+  {  %error for now, perhaps warning later.
+    \PackageError{newpax}
+     {
+       PDF~resource~management~code~not~found!\MessageBreak
+       newpage~will~no~work.
+     }
+     {
+       Load~it~with \MessageBreak
+       \string\RequirePackage{pdfmanagement-testphase}\MessageBreak
+       before~loading~the~class
+     }
+  }
+
+\ExplSyntaxOff
+\RequirePackage{graphicx}
+\RequirePackage{ltxcmds}[2011/04/18]
+\RequirePackage{kvsetkeys}[2011/04/07]
+\RequirePackage{kvoptions}[2010/12/23]
+\RequirePackage{auxhook}[2011/03/04]
+\RequirePackage{etoolbox}
+\RequirePackage{xfp}
+
+\ExplSyntaxOn
+%to replace \pdf at strcmp
+\cs_set_eq:NN \newpax at str@if at eq@@@@nnT\str_if_eq:nnT
+
+\bool_new:N \l_@@_use_attributes_bool
+\bool_new:N \l_@@_addannots_bool
+
+\tl_new:N   \l_@@_destsuffix_tl
+\tl_new:N \NEWPAX at fileextension
+
+\cs_generate_variant:Nn \pdfannot_dict_put:nnn {nnx,xnx,xnn}
+\NewDocumentCommand\newpaxsetup { m }
+  {
+    \keys_set:nn {newpax}{ #1}
+  }
+
+\keys_define:nn {newpax}
+  {
+    usefileattributes .bool_set:N = \l_@@_use_attributes_bool,
+    destsuffix        .tl_set:N   = \l_@@_destsuffix_tl,
+    addannots         .bool_set:N = \l_@@_addannots_bool,
+    addannots         .default:n  = true,
+    addannots         .initial:n  = true,
+    paxextension      .choices:nn =
+       {pax,newpax}
+       {\tl_set:Nn \NEWPAX at fileextension {#1}},
+    paxextension .initial:n = newpax
+  }
+
+\cs_new_protected:Npn \@NEWPAX at setattributes@n #1 %link type
+  {
+    \bool_if:NT \l_@@_use_attributes_bool
+      {
+        \tl_if_empty:NTF  \NEWPAX at key@C
+          {
+            \pdfannot_dict_remove:nn {link/#1} { C }
+          }
+          {
+            \pdfannot_dict_put:nnx
+              {link/#1}
+              { C }
+              { \NEWPAX at key@C }
+          }
+        \tl_if_empty:NTF \NEWPAX at key@Border
+          {
+            \pdfannot_dict_remove:nn {link/#1} { Border }
+          }
+          {
+            \pdfannot_dict_put:nnx
+              {link/#1}
+              { Border }
+              { \NEWPAX at key@Border }
+          }
+        \tl_if_empty:NTF \NEWPAX at key@BS
+          {
+            \pdfannot_dict_remove:nn {link/#1} { BS }
+          }
+          {
+            \pdfannot_dict_put:nnx
+              {link/#1}
+              { BS }
+              { \NEWPAX at key@BS }
+          }
+        \tl_if_empty:NTF \NEWPAX at key@H
+          {
+            \pdfannot_dict_remove:nn {link/#1} { H }
+          }
+          {
+            \pdfannot_dict_put:nnx
+              {link/#1}
+              { H }
+              { \NEWPAX at key@H }
+          }
+      }
+  }
+
+
+
+
+\cs_new_protected:Npn \@NEWPAX at linkgoto@xnn #1 #2 #3  %#1 dest #2 width #3 height
+  {
+    \group_begin:
+      \exp_args:Nx\@NEWPAX at setattributes@n {GoTo}
+      \leavevmode
+      \exp_args:Nx\pdfannot_link_goto_begin:nw
+        { #1 }
+        \@NEWPAX at ensurelinkbox@n{\hbox_to_wd:nn {#2}{ { \rule{0pt}{#3} }\hfill}}
+      \pdfannot_link_goto_end:
+    \group_end:
+  }
+
+\cs_new_protected:Npn \@NEWPAX at link@setaction at nn #1 #2
+ {
+    \pdfannot_dict_put:nnn{link/#1}{Subtype}{/Link}
+    \pdfannot_dict_put:nnx{link/#1}{A}
+       {<</Type/Action/S/#1 #2>>}
+ }
+
+
+
+\cs_new_protected:Npn \@NEWPAX at annotboxlink@nnn #1 #2 #3   %#1 type, #2 width #3 height
+  {
+    \group_begin:
+      \exp_args:Nx\@NEWPAX at setattributes@n {#1}
+      \leavevmode
+      \pdfannot_box:nnnx {#2}{#3}{0pt}
+         {\pdfannot_dict_use:n{link/#1}}
+    \group_end:
+  }
+
+\cs_new_protected:Npn \@NEWPAX at destination@xx #1 #2
+  {
+    \exp_args:Nxx \pdf_destination:nn {#1}{#2}
+  }
+
+% only defined if hyperref is loaded ...
+\sys_if_engine_xetex:TF
+  {
+    \cs_set_eq:NN \@NEWPAX at ensurelinkbox@n \XeTeXLinkBox
+  }
+  {
+    \cs_set_eq:NN \@NEWPAX at ensurelinkbox@n \use:n
+  }
+\ExplSyntaxOff
+% Hook into \includegraphics of graphicx with one optional
+% star, one optional argument with key value pairs and
+% the graphics name
+\let\NEWPAX at ORG@includegraphics\includegraphics
+\def\includegraphics{%
+  \@ifstar{%
+    \@ifnextchar[{%
+      \begingroup
+        \def\x{\endgroup
+           \NEWPAX at includegraphics[clip,%
+        }%
+      \expandafter\x\@gobble
+    }{%
+      \NEWPAX at includegraphics[clip]%
+    }%
+  }{%
+    \@ifnextchar[{%
+      \NEWPAX at includegraphics
+    }{%
+      \NEWPAX at includegraphics[]%
+    }%
+  }%
+}
+
+\ExplSyntaxOn
+\def\NEWPAX at includegraphics[#1]#2{%
+  \begingroup
+    \sbox0{\NEWPAX at ORG@includegraphics[{#1}]{#2}}%
+    \edef\NEWPAX at inc@width{\the\wd0}%
+    \edef\NEWPAX at inc@height{\the\dimexpr\dp0+\ht0}%
+    \leavevmode
+    \hbox to \wd0{%
+      \rlap{\copy0}%
+      \bool_if:nT
+        { \l_@@_addannots_bool
+           &&
+           (
+            \int_compare_p:nNn
+             {
+               \cs_if_exist:NTF\pdfpages at includegraphics@status
+                 {
+                    \pdfpages at includegraphics@status
+                 }{0}
+             }
+             <
+             {2}
+           )
+        }
+        {
+          \raise-\dp0\hbox
+            {
+              \NEWPAX at AddAnnots{#1}{#2}%
+            }
+        }
+      \hfill
+    }
+  \endgroup
+}
+\ExplSyntaxOff
+\SetupKeyvalOptions{family=NEWPAX at Gin,prefix=NEWPAX at Gin@}
+\DeclareStringOption[1]{page}
+\DeclareStringOption[0]{angle}
+\DeclareBoolOption{clip}
+\define at key{NEWPAX at Gin}{viewport}{%
+  \ltx at LocalAppendToMacro\NEWPAX at Gin@box at opts{%
+    \NEWPAX at viewport#1\\%
+  }%
+}
+\define at key{NEWPAX at Gin}{trim}{%
+  \ltx at LocalAppendToMacro\NEWPAX at Gin@box at opts{%
+    \NEWPAX at trim#1\\%
+  }%
+}
+\let\NEWPAX at Gin@box at opts\@empty
+
+\def\NEWPAX at viewport#1 #2 #3 #4\\{%
+  \NEWPAX at defaultbp\NEWPAX at vllx{#1}%
+  \NEWPAX at defaultbp\NEWPAX at vlly{#2}%
+  \NEWPAX at defaultbp\NEWPAX at vurx{#3}%
+  \NEWPAX at defaultbp\NEWPAX at vury{#4}%
+  \edef\NEWPAX at page@llx{\dimexpr\NEWPAX at page@llx+\NEWPAX at vllx\relax}%
+  \edef\NEWPAX at page@lly{\dimexpr\NEWPAX at page@lly+\NEWPAX at vlly\relax}%
+  \edef\NEWPAX at page@urx{\dimexpr\NEWPAX at page@llx+\NEWPAX at vlly\relax}%
+  \edef\NEWPAX at page@ury{\dimexpr\NEWPAX at page@lly+\NEWPAX at vury\relax}%
+}
+\def\NEWPAX at trim#1 #2 #3 #4\\{%
+  \NEWPAX at defaultbp\NEWPAX at tllx{#1}%
+  \NEWPAX at defaultbp\NEWPAX at tlly{#2}%
+  \NEWPAX at defaultbp\NEWPAX at turx{#3}%
+  \NEWPAX at defaultbp\NEWPAX at tury{#4}%
+  \edef\NEWPAX at page@llx{\dimexpr\NEWPAX at page@llx+\NEWPAX at tllx\relax}%
+  \edef\NEWPAX at page@lly{\dimexpr\NEWPAX at page@lly+\NEWPAX at tlly\relax}%
+  \edef\NEWPAX at page@urx{\dimexpr\NEWPAX at page@urx-\NEWPAX at turx\relax}%
+  \edef\NEWPAX at page@ury{\dimexpr\NEWPAX at page@ury-\NEWPAX at tury\relax}%
+}
+
+\def\NEWPAX at defaultbp#1#2{%
+  \afterassignment\NEWPAX at def@bp\dimen@#2bp\relax{#1}{#2}%
+}
+\def\NEWPAX at def@bp#1\relax#2#3{%
+  \if!#1!%
+    \edef#2{#3bp}%
+  \else
+    \edef#2{#3}%
+  \fi
+}
+
+% ignore unknown options in family `NEWPAX at Gin'
+\kv at set@family at handler{NEWPAX at Gin}{}
+
+\def\NEWPAX at AddAnnots#1#2{%
+  \kvsetkeys{NEWPAX at Gin}{#1}%
+  \Grot at setangle{\NEWPAX at Gin@angle}%
+  % a little careful, is type of angle int or real?
+  \loop
+  \ifdim\NEWPAX at Gin@angle\p@<360\p@
+  \else
+    \edef\NEWPAX at Gin@angle{\the\numexpr-360+\number\NEWPAX at Gin@angle}%
+  \repeat
+  \loop
+  \ifdim\NEWPAX at Gin@angle\p@<\z@
+    \edef\NEWPAX at Gin@angle{\strip at pt\dimexpr\NEWPAX at Gin@angle\p at +360\p@}%
+  \repeat
+  \ifcase0\ifnum\NEWPAX at Gin@angle=0 1\fi
+          \ifnum\NEWPAX at Gin@angle=90 1\fi
+          \ifnum\NEWPAX at Gin@angle=180 1\fi
+          \ifnum\NEWPAX at Gin@angle=270 1\fi
+    \PackageWarning{newpax}{Unsupported value for option angle}%
+  \fi
+  \filename at parse{#2}%
+  \def\NEWPAX at file{%\filename at area
+  \filename at base.\NEWPAX at fileextension }%
+  \let\[\NEWPAX at parser
+  \def\<{<}%
+  \def\>{>}%
+  \endlinechar=-1 %
+  \begingroup
+  \catcode`\#=12 \catcode`\%=12
+  \InputIfFileExists\NEWPAX at file{}{\typeout{* Missing: \NEWPAX at file}}\endgroup
+}
+\def\NEWPAX at parser#1{\NEWPAX at call{cmd}{#1}{}}%
+\def\NEWPAX at call#1#2#3{%
+  \@ifundefined{NEWPAX@#1@#2}\NEWPAX at skip{#3\csname NEWPAX@#1@#2\endcsname}%
+}
+\def\NEWPAX at skip#1\\{}
+\def\NEWPAX at stop#1\\{}
+
+\def\NEWPAX at cmd@page#1#2{%
+  \NEWPAX at filter@page{#1}{%
+    \NEWPAX at getrect{page}#2\@nil
+    \NEWPAX at Gin@box at opts
+    \ifcase0\ifnum\NEWPAX at Gin@angle=90 1\fi
+            \ifnum\NEWPAX at Gin@angle=270 1\fi
+    \else
+      \let\NEWPAX at temp\NEWPAX at inc@width
+      \let\NEWPAX at inc@width\NEWPAX at inc@height
+      \let\NEWPAX at inc@height\NEWPAX at temp
+    \fi
+    \Gscale at div\NEWPAX at scale@x\NEWPAX at inc@width{%
+      \dimexpr\NEWPAX at page@urx-\NEWPAX at page@llx\relax
+    }%
+    \Gscale at div\NEWPAX at scale@y\NEWPAX at inc@height{%
+      \dimexpr\NEWPAX at page@ury-\NEWPAX at page@lly\relax
+    }%
+    \NEWPAX at skip
+  }%
+}
+\def\NEWPAX at filter@page#1{%
+  \ifnum\NEWPAX at Gin@page=#1 %
+    \expandafter\@firstofone
+  \else
+    \ifnum\NEWPAX at Gin@page<#1 %
+      \csname fi\endcsname
+      \csname fi\endcsname
+      \expandafter\NEWPAX at stop\@gobblefour
+    \fi
+    \expandafter\NEWPAX at skip
+  \fi
+}
+\def\NEWPAX at getrect#1#2 #3 #4 #5\@nil{%
+  \@namedef{NEWPAX@#1 at llx}{#2bp}%
+  \@namedef{NEWPAX@#1 at lly}{#3bp}%
+  \@namedef{NEWPAX@#1 at urx}{#4bp}%
+  \@namedef{NEWPAX@#1 at ury}{#5bp}%
+}
+
+\def\NEWPAX at cmd@annot#1#2{%
+  \NEWPAX at filter@page{#1}{%
+    \NEWPAX at call{annot}{#2}{}%
+  }%
+}
+\def\NEWPAX at annot@Link#1#2#3{%
+  \def\NEWPAX at link@type{#2}%
+  \NEWPAX at call{link}{#2}{%
+    \begingroup
+    \NEWPAX at getrect{annot}#1\@nil
+    \kvsetkeys{NEWPAX}{#3}%
+  }%
+  \NEWPAX at skip
+}
+\newif\ifNEWPAX at ok
+\NEWPAX at oktrue
+
+\newif\ifNEWPAX at GoTo
+
+\def\NEWPAX at pdf@annot#1{%
+  \ifNEWPAX at Gin@clip
+    \ifdim\NEWPAX at annot@llx<\NEWPAX at page@llx
+      \let\NEWPAX at annot@llx\NEWPAX at page@llx
+    \fi
+    \ifdim\NEWPAX at annot@lly<\NEWPAX at page@lly
+      \let\NEWPAX at annot@lly\NEWPAX at page@lly
+    \fi
+    \ifdim\NEWPAX at annot@urx>\NEWPAX at page@urx
+      \let\NEWPAX at annot@urx\NEWPAX at page@urx
+    \fi
+    \ifdim\NEWPAX at annot@ury>\NEWPAX at page@ury
+      \let\NEWPAX at annot@ury\NEWPAX at page@ury
+    \fi
+    \NEWPAX at okfalse
+    \ifdim\NEWPAX at annot@llx<\NEWPAX at annot@urx\relax
+      \ifdim\NEWPAX at annot@lly<\NEWPAX at annot@ury\relax
+        \NEWPAX at oktrue
+      \fi
+    \fi
+  \else
+    \NEWPAX at oktrue
+  \fi
+  \ifNEWPAX at ok
+    \ifcase 0\ifnum\NEWPAX at Gin@angle=90 1\fi
+             \ifnum\NEWPAX at Gin@angle=180 2\fi
+             \ifnum\NEWPAX at Gin@angle=270 3\fi\space
+      % angle = 0
+      \def\NEWPAX at raise{%
+        \NEWPAX at scale@y\dimexpr\NEWPAX at annot@lly-\NEWPAX at page@lly\relax
+      }%
+      \def\NEWPAX at right{%
+        \NEWPAX at scale@x\dimexpr\NEWPAX at annot@llx-\NEWPAX at page@llx\relax
+      }%
+    \or % angle = 90
+      \def\NEWPAX at raise{%
+        \NEWPAX at scale@x\dimexpr\NEWPAX at annot@llx-\NEWPAX at page@llx\relax
+      }%
+      \def\NEWPAX at right{%
+        \NEWPAX at scale@y\dimexpr\NEWPAX at page@ury-\NEWPAX at annot@ury\relax
+      }%
+    \or % angle = 180
+      \def\NEWPAX at raise{%
+        \NEWPAX at scale@y\dimexpr\NEWPAX at page@ury-\NEWPAX at annot@ury\relax
+      }%
+      \def\NEWPAX at right{%
+        \NEWPAX at scale@x\dimexpr\NEWPAX at page@urx-\NEWPAX at annot@urx\relax
+      }%
+    \or % angle = 270
+      \def\NEWPAX at raise{%
+        \NEWPAX at scale@x\dimexpr\NEWPAX at page@urx-\NEWPAX at annot@urx\relax
+      }%
+      \def\NEWPAX at right{%
+        \NEWPAX at scale@y\dimexpr\NEWPAX at annot@lly-\NEWPAX at page@lly\relax
+      }%
+    \fi
+    \@namedef{%
+      NEWPAX@%
+      \ifcase0\ifnum\NEWPAX at Gin@angle=90 1\fi
+              \ifnum\NEWPAX at Gin@angle=270 1\fi\space
+        width%
+      \else
+        height%
+      \fi
+    }{%
+      \NEWPAX at scale@x\dimexpr\NEWPAX at annot@urx-\NEWPAX at annot@llx\relax
+    }%
+    \@namedef{%
+      NEWPAX@%
+      \ifcase0\ifnum\NEWPAX at Gin@angle=90 1\fi
+              \ifnum\NEWPAX at Gin@angle=270 1\fi\space
+        height%
+      \else
+        width%
+      \fi
+    }{%
+      \NEWPAX at scale@y\dimexpr\NEWPAX at annot@ury-\NEWPAX at annot@lly\relax
+    }%
+    \raise\NEWPAX at raise\hb at xt@\z@{%
+      \kern\NEWPAX at right
+      \ifNEWPAX at GoTo
+        %additional box for lualatex ...
+        \hbox{%
+          \@NEWPAX at linkgoto@xnn
+            {NEWPAX@\NEWPAX at file @\NEWPAX at key@DestLabel @\csname l_@@_destsuffix_tl\endcsname}%
+            {\NEWPAX at width}%
+            {\NEWPAX at height}%
+            }%
+      \else
+        \hbox{%
+        \expandafter\@NEWPAX at link@setaction at nn\expandafter{\NEWPAX at link@type}{#1}%
+        \expandafter
+         \@NEWPAX at annotboxlink@nnn
+         \expandafter {\NEWPAX at link@type}{\NEWPAX at width}{\NEWPAX at height}{}}%
+      \fi
+      \hss
+    }%
+  \fi
+  \endgroup
+}
+
+
+\def\NEWPAX at htype@GoToR{file}
+\def\NEWPAX at htype@GoTo{link}
+\def\NEWPAX at htype@Named{link}
+\def\NEWPAX at htype@URI{url}
+
+\def\NEWPAX at link@URI{%
+  \NEWPAX at pdf@annot{%
+    /URI\NEWPAX at key@URI
+  }%
+}
+\ExplSyntaxOn
+\def\NEWPAX at link@Named{%
+  \NEWPAX at pdf@annot{%
+    /N \pdf_name_from_unicode_e:n{\NEWPAX at key@Name} %the value is from a pdf so we can assume it is correctly escaped??
+  }%
+}
+\ExplSyntaxOff
+\def\NEWPAX at link@GoToR{%
+  \NEWPAX at pdf@annot{%
+    /F\NEWPAX at key@File
+    /D%
+    \ifx\NEWPAX at key@DestName\@empty
+      [\NEWPAX at key@DestPage\space\NEWPAX at key@DestView]%
+    \else
+      \NEWPAX at key@DestName
+    \fi
+  }%
+}
+
+% GoTo
+
+\AddLineBeginAux{%
+  \string\providecommand{\string\NEWPAX at DestReq}[2]{}%
+}
+\AddLineBeginAux{%
+  \string\providecommand{\string\NEWPAX at DestProv}[2]{}%
+}
+\AtBeginDocument{%
+  \let\NEWPAX at DestReq\@gobbletwo
+  \let\NEWPAX at DestProv\@gobbletwo
+}
+\def\NEWPAX at DestReq#1#2{%
+  \expandafter\gdef\csname NEWPAX at REQ@#1@#2\endcsname{}%
+}
+\def\NEWPAX at DestProv#1#2{%
+  \expandafter\gdef\csname NEWPAX at PROV@#1@#2\endcsname{}%
+}
+
+\def\NEWPAX at link@GoTo{%
+  \ifnum0<0\NEWPAX at key@DestLabel\relax
+    \expandafter\@firstofone
+  \else
+    \endgroup
+    \expandafter\@gobble
+  \fi
+  {%
+    \if at filesw
+      \protected at write\@auxout{}{%
+        \string\NEWPAX at DestReq{\NEWPAX at file}{\NEWPAX at key@DestLabel}%
+      }%
+    \fi
+    % Generate link, if destination exists
+    \@ifundefined{NEWPAX at PROV@\NEWPAX at file @\NEWPAX at key@DestLabel}{%
+      \endgroup
+    }{%
+      \NEWPAX at GoTotrue
+      \NEWPAX at pdf@annot{}%
+    }%
+  }%
+}
+
+% Read destinations
+\def\NEWPAX at cmd@dest#1#2#3#4{%
+  \NEWPAX at filter@page{#1}{%
+    \if at filesw
+      \protected at write\@auxout{}{%
+        \string\NEWPAX at DestProv{\NEWPAX at file}{#2}%
+      }%
+    \fi
+    \@ifundefined{NEWPAX at REQ@\NEWPAX at file @#2}{%
+    }{%
+      \begingroup
+        \let\NEWPAX at key@DestY\NEWPAX at page@ury
+        \let\NEWPAX at key@DestX\NEWPAX at page@llx
+        \kvsetkeys{NEWPAX}{#4}%
+        \let\NEWPAX at dest@llx\NEWPAX at key@DestX
+        \let\NEWPAX at dest@urx\NEWPAX at key@DestX
+        \let\NEWPAX at dest@lly\NEWPAX at key@DestY
+        \let\NEWPAX at dest@ury\NEWPAX at key@DestY
+        \ifx\NEWPAX at key@DestRect\@empty
+        \else
+          \def\NEWPAX at temp{dest}%
+          \expandafter\NEWPAX at getrect\expandafter\NEWPAX at temp
+          \NEWPAX at key@DestRect\@nil
+        \fi
+        \ifNEWPAX at Gin@clip
+          \ifx\NEWPAX at dest@llx<\NEWPAX at page@llx
+            \let\NEWPAX at dest@llx\NEWPAX at page@llx
+          \fi
+          \ifx\NEWPAX at dest@lly<\NEWPAX at page@lly
+            \let\NEWPAX at dest@lly\NEWPAX at page@lly
+          \fi
+          \ifx\NEWPAX at dest@urx>\NEWPAX at page@urx
+            \let\NEWPAX at dest@urx\NEWPAX at page@urx
+          \fi
+          \ifx\NEWPAX at dest@ury>\NEWPAX at page@ury
+            \let\NEWPAX at dest@ury\NEWPAX at page@ury
+          \fi
+          % at least prevent destinations outside the window
+          \ifx\NEWPAX at dest@llx>\NEWPAX at page@urx
+            \NEWPAX at dest@llx\NEWPAX at page@urx
+          \fi
+          \ifx\NEWPAX at dest@lly>\NEWPAX at page@ury
+            \NEWPAX at dest@lly\NEWPAX at page@ury
+          \fi
+          \ifx\NEWPAX at dest@urx<\NEWPAX at page@llx
+            \NEWPAX at dest@urx\NEWPAX at page@llx
+          \fi
+          \ifx\NEWPAX at dest@ury<\NEWPAX at page@lly
+            \NEWPAX at dest@ury\NEWPAX at page@lly
+          \fi
+        \fi
+        % I don't know, what is the best idea for rotated stuff,
+        % perhaps using the corner llx/ury
+        \ifcase 0\ifnum\NEWPAX at Gin@angle=90 1\fi
+                 \ifnum\NEWPAX at Gin@angle=180 2\fi
+                 \ifnum\NEWPAX at Gin@angle=270 3\fi\space
+          % angle = 0
+          \def\NEWPAX at raise{%
+            \NEWPAX at scale@y\dimexpr\NEWPAX at dest@lly-\NEWPAX at page@lly\relax
+          }%
+          \def\NEWPAX at right{%
+            \NEWPAX at scale@x\dimexpr\NEWPAX at dest@llx-\NEWPAX at page@llx\relax
+          }%
+        \or % angle = 90
+          \def\NEWPAX at raise{%
+            \NEWPAX at scale@x\dimexpr\NEWPAX at dest@llx-\NEWPAX at page@llx\relax
+          }%
+          \def\NEWPAX at right{%
+            \NEWPAX at scale@y\dimexpr\NEWPAX at page@ury-\NEWPAX at dest@ury\relax
+          }%
+        \or % angle = 180
+          \def\NEWPAX at raise{%
+            \NEWPAX at scale@y\dimexpr\NEWPAX at page@ury-\NEWPAX at dest@ury\relax
+          }%
+          \def\NEWPAX at right{%
+            \NEWPAX at scale@x\dimexpr\NEWPAX at page@urx-\NEWPAX at dest@urx\relax
+          }%
+        \or % angle = 270
+          \def\NEWPAX at raise{%
+            \NEWPAX at scale@x\dimexpr\NEWPAX at page@urx-\NEWPAX at dest@urx\relax
+          }%
+          \def\NEWPAX at right{%
+            \NEWPAX at scale@y\dimexpr\NEWPAX at dest@lly-\NEWPAX at page@lly\relax
+          }%
+        \fi
+        \edef\NEWPAX at name{NEWPAX@\NEWPAX at file @#2@\csname l_@@_destsuffix_tl\endcsname}%
+        \let\NEWPAX at type\@empty
+        \newpax at str@if at eq@@@@nnT{#3}{FITR}{\def\NEWPAX at type{xyz}}%too lazy for now for better fitr
+        \newpax at str@if at eq@@@@nnT{#3}{XYZ}
+          {%
+            \def\NEWPAX at type{xyz}%
+            \ifx\NEWPAX at key@DestZoom\@empty
+            \else
+             \edef\NEWPAX at type{\fpeval{\NEWPAX at key@DestZoom *100}}%
+            \fi
+          }
+        \newpax at str@if at eq@@@@nnT{#3}{FIT}{\def\NEWPAX at type{fit}}
+        \newpax at str@if at eq@@@@nnT{#3}{FITB}{\def\NEWPAX at type{fitb}}
+        \newpax at str@if at eq@@@@nnT{#3}{FITH}{\def\NEWPAX at type{fith}}
+        \newpax at str@if at eq@@@@nnT{#3}{FITBH}{\def\NEWPAX at type{fitbh}}
+        \newpax at str@if at eq@@@@nnT{#3}{FITV}{\def\NEWPAX at type{fitv}}
+        \newpax at str@if at eq@@@@nnT{#3}{FITBV}{\def\NEWPAX at type{fitbv}}
+        \ifx\NEWPAX at type\@empty
+          \def\NEWPAX at type{xyz}%
+        \fi
+        \raise\NEWPAX at raise\hb at xt@\z@{%
+          \kern\NEWPAX at right
+          \hbox{\@NEWPAX at destination@xx {\NEWPAX at name}{\NEWPAX at type}}%
+          \hss
+        }%
+      \endgroup
+    }%
+    \NEWPAX at skip
+  }%
+}
+
+\SetupKeyvalOptions{family=NEWPAX,prefix=NEWPAX at key@}
+\DeclareStringOption{URI}
+\DeclareStringOption{Name}
+\DeclareStringOption{DestName}
+\DeclareStringOption{DestPage}
+\DeclareStringOption{DestView}
+\DeclareStringOption{File}
+\DeclareStringOption{C}
+\DeclareStringOption{Border}
+\DeclareStringOption{BS}
+\DeclareStringOption{H}
+\DeclareStringOption{DestLabel}
+\DeclareStringOption{DestRect}
+\DeclareStringOption{DestZoom}
+\define at key{NEWPAX}{DestX}{%
+  \NEWPAX at defaultbp\NEWPAX at key@DestX{#1}%
+}
+\define at key{NEWPAX}{DestY}{%
+  \NEWPAX at defaultbp\NEWPAX at key@DestY{#1}%
+}
+%</package>
+%    \end{macrocode}
+%    \begin{macrocode}
+%<*lua>
+local ProvidesLuaModule = {
+    name          = "newpax",
+    version       = "0.51",       --TAGVERSION
+    date          = "2021-03-07", --TAGDATE
+    description   = "newpax lua code",
+    license       = "The LATEX Project Public License 1.3c"
+}
+
+if luatexbase and luatexbase.provides_module then
+  luatexbase.provides_module (ProvidesLuaModule)
+end
+
+
+
+local OPEN              = pdfe.open
+local GETSIZE           = pdfe.getsize
+local GETINFO           = pdfe.getinfo
+local GETPAGE           = pdfe.getpage
+local GETNAME           = pdfe.getname
+local GETARRAY          = pdfe.getarray
+local GETDICTIONARY     = pdfe.getdictionary
+local GETFROMDICTIONARY = pdfe.getfromdictionary
+local GETFROMARRAY      = pdfe.getfromarray
+local PAGESTOTABLE      = pdfe.pagestotable
+local DICTIONARYTOTABLE = pdfe.dictionarytotable
+local ARRAYTOTABLE      = pdfe.arraytotable
+local TYPE              = pdfe.type
+local GETFROMREFERENCE  = pdfe.getfromreference
+local FILENAMEONLY      = file.nameonly
+
+local strENTRY_BEG = "\\["
+local strENTRY_END = "\\\\\n"
+local strCMD_BEG = "{"
+local strCMD_END = "}"
+local strARG_BEG = "{"
+local strARG_END = "}"
+local strKVS_BEG = "{"
+local strKVS_END = "\n}"
+local strKVS_EMPTY = "{}"
+local strKV_BEG  = "\n  "
+local strKV_END  = ","
+local strKEY_BEG = ""
+local strKEY_END = ""
+local strVALUE_BEG = "={"
+local strVALUE_END = "}"
+local strHEX_STR_BEG = "\\<"
+local strHEX_STR_END = "\\>"
+
+
+local strLIT_STR_BEG = "("
+local strLIT_STR_END = ")"
+local strDICT_BEG= "<<"
+local strDICT_END= ">>"
+local strNAME= "/"
+local strARRAY_BEG= "["
+local strARRAY_END= "]"
+local strARRAY_SEP = " "
+local strRECT_SEP = " "
+
+
+local constCMD_ANNOT   = "annot"
+local constCMD_BASEURL = "baseurl" -- unused
+local constCMD_DEST    = "dest"
+local constCMD_FILE    = "file"
+local constCMD_INFO    = "info"   -- unused
+local constCMD_PAGENUM = "pagenum"
+local constCMD_PAGE    = "page"
+local constCMD_PAX     = "pax"
+
+-- cmd file
+local constKEY_SIZE    = "Size"
+local constKEY_DATE    = "Date"
+
+-- cmd annot attributes
+local constKEY_C      = "C"
+local constKEY_BORDER = "Border"
+local constKEY_BS     = "BS"
+local constKEY_H      = "H"
+
+-- cmd annot/link/URI
+local constKEY_URI    = "URI"
+local constKEY_IS_MAP = "IsMap" -- not handled by pax, consider later
+
+
+-- cmd annot/link/GoToR
+local constKEY_FILE      = "File"
+local constKEY_DEST_NAME = "DestName" -- handle??
+local constKEY_DEST_PAGE = "DestPage" --ok
+local constKEY_DEST_VIEW = "DestView" --ok
+
+-- cmd annot/link/GoTo
+local constKEY_DEST_RECT  = "DestRect"
+local constKEY_DEST_X     = "DestX"
+local constKEY_DEST_Y     = "DestY"
+local constKEY_DEST_ZOOM  = "DestZoom"
+local constKEY_DEST_LABEL = "DestLabel" --ok
+
+-- cmd annot/link/Named
+local constKEY_NAME = "Name"
+
+-- destination views
+local constDEST_XYZ = "XYZ"
+local constDEST_FIT    = "Fit"
+local constDEST_FITH   = "FitH"
+local constDEST_FITV   = "FitV"
+local constDEST_FITR   = "FitR"
+local constDEST_FITB   = "FitB"
+local constDEST_FITBH  = "FitBH"
+local constDEST_FITBV  = "FitBV"
+
+
+-- get/build data
+-- returns table,pagecount where table objref ->page number
+local function getpagesdata (pdfedoc)
+  local type,pagecount,detail   = GETFROMDICTIONARY (pdfedoc.Catalog.Pages,"Count")
+  local pagestable  = PAGESTOTABLE (pdfedoc)
+  local pagereftonum ={}
+  for i=1,#pagestable do
+   pagereftonum[pagestable[i][3]]=i
+  end
+  return pagereftonum, pagecount
+end
+
+-- builds a table destination name -> obj reference (pdfedict) from the Names tree
+
+local function processnamesarray (pdfearray,targettable)
+  local tkey={}
+  for i=1,#pdfearray do
+    local type,value,detail= GETFROMARRAY(pdfearray,i)
+    if (i % 2 == 1) then
+     tkey = value
+    else
+      tvalue = value
+      targettable[tkey]=tvalue
+    end
+  end
+end
+
+local function findallnamesarrays (pdfedict,deststable)
+  local namesarray  = GETARRAY(pdfedict,"Names")
+  if namesarray then
+     processnamesarray (namesarray,deststable)
+  else
+     local kidsarray = GETARRAY(pdfedict,"Kids")
+     if kidsarray then
+       for i=1,#kidsarray do
+         findallnamesarrays (kidsarray[i],deststable)
+       end
+     end
+  end
+end
+
+-- returns destnames -> objref table
+local function getdestreferences (pdfedoc)
+  local deststable= {}
+  local catnames  = GETDICTIONARY (pdfedoc.Catalog, "Names")
+  if catnames then
+    local destsdict = GETDICTIONARY (catnames, "Dests")
+    if destsdict then
+      findallnamesarrays (destsdict,deststable)
+    end
+  end
+  return deststable
+end
+
+-- destinations can be an dict (/D [array]) or only an array!
+
+local function getdestdata (name,pagereftonum,destnamestoref)
+   local destref = destnamestoref[name]
+   local type,ref,pagenum,destx,desty = nil, nil, 1,0,0
+   local data = {{0,0}, {5,constDEST_XYZ}}
+   if destref then
+     type,value,detail = GETFROMREFERENCE(destref)
+     if TYPE(value) == "pdfe.dictionary" then
+       local destarray = GETARRAY(value,"D")
+       if destarray then
+         data = ARRAYTOTABLE(destarray)
+         type, ref, pageref = GETFROMARRAY(destarray,1)
+         pagenum = pagereftonum[pageref]
+       end
+     elseif TYPE(value) == "pdfe.array" then
+        data = ARRAYTOTABLE(value)
+        type, ref, pageref = GETFROMARRAY(value,1)
+        pagenum = pagereftonum[pageref]
+     end
+   end
+  return pagenum, data
+end
+
+-- output functions
+-- write the info
+-- XXXXXX encode/escape the file name?
+local function outputENTRY_file (file, pdfedoc)
+  local bytes       = GETSIZE(pdfedoc)
+  local date        = GETINFO(pdfedoc).CreationDate
+  -- file
+  local a = strENTRY_BEG
+  a = a .. strCMD_BEG .. constCMD_FILE .. strCMD_END
+  a = a .. strARG_BEG .. strLIT_STR_BEG .. file .. strLIT_STR_END ..  strARG_END
+  a = a .. strKVS_BEG
+   a = a .. strKV_BEG .. constKEY_SIZE .. strVALUE_BEG .. bytes .. strVALUE_END .. strKV_END
+   a = a .. strKV_BEG .. constKEY_DATE .. strVALUE_BEG .. date .. strVALUE_END.. strKV_END
+  a = a .. strKVS_END
+  a = a .. strENTRY_END
+  return a
+end
+
+local function outputENTRY_pagenum (pages)
+  local a = strENTRY_BEG
+  a = a .. strCMD_BEG .. constCMD_PAGENUM .. strCMD_END
+  a = a .. strARG_BEG .. pages .. strARG_END
+  a = a .. strENTRY_END
+  return a
+end
+
+local function outputENTRY_page (pdfedoc,page) -- page=integer
+  -- trimbox, bleedbox, cropbox,artbox,rotate etc could be put in
+  -- the second argument as keyval:
+  -- TrimBox={0 0 300 350},
+  -- but pax skips the argument anyway, so not really useful
+  local mediabox = pdfe.getbox(GETPAGE(pdfedoc,page),"MediaBox")
+  local a=""
+  if mediabox then
+    a = strENTRY_BEG
+    a = a .. strCMD_BEG .. constCMD_PAGE .. strCMD_END
+    a = a .. strARG_BEG .. page .. strARG_END
+    a = a .. strARG_BEG
+      a = a .. mediabox[1]
+      for j = 2, 4 do
+       a = a .. strRECT_SEP.. mediabox[j]
+      end
+    a = a .. strARG_END
+    a = a .. strKVS_EMPTY
+    a = a .. strENTRY_END
+  end
+  return a
+end
+
+
+local function outputCMD_annot (pdfedict,page,type)
+  local rectangle = ARRAYTOTABLE(GETARRAY(pdfedict,"Rect"))
+  local a = strCMD_BEG .. constCMD_ANNOT .. strCMD_END
+      a = a .. strARG_BEG .. page .. strARG_END
+      a = a .. strARG_BEG .. GETNAME(pdfedict,"Subtype") .. strARG_END
+      a = a .. strARG_BEG
+       a = a .. rectangle[1][2]
+        for k = 2, 4 do
+         a = a.. strRECT_SEP..rectangle[k][2]
+        end
+      a = a .. strARG_END
+      a = a .. strARG_BEG .. type .. strARG_END
+  return a
+end
+
+
+local function outputKV_color (pdfedict)
+  local color = GETARRAY(pdfedict,constKEY_C)
+  local a =""
+  if color then
+    local colortable = ARRAYTOTABLE(color)
+    a = strKV_BEG .. constKEY_C .. strVALUE_BEG .. strARRAY_BEG
+      for i=1,#colortable do
+        a = a.. colortable[i][2] .. strARRAY_SEP
+      end
+    a = a .. strARRAY_END .. strVALUE_END .. strKV_END
+  end
+  return a
+end
+
+local function outputKV_key (pdfedict,key)
+  local name = GETNAME(pdfedict,key)
+  local a = ""
+  if name then
+    a = strKV_BEG .. key .. strVALUE_BEG .. strNAME .. name .. strVALUE_END .. strKV_END
+  end
+  return a
+end
+
+-- XXX handle fourth argument
+local function outputKV_Border (pdfedict)
+  local border = GETARRAY(pdfedict,constKEY_BORDER)
+  local a =""
+  if border then
+    local bordertable = ARRAYTOTABLE(border)
+    a = strKV_BEG .. constKEY_BORDER .. strVALUE_BEG .. strARRAY_BEG
+    for i=1,3 do
+      a = a .. bordertable[i][2] .. strARRAY_SEP
+    end
+ -- fourth argument later, it is an array (type 7)
+   a = a ..strARRAY_END .. strVALUE_END .. strKV_END
+  end
+  return a
+end
+
+local function outputKV_BS (pdfedict)
+  local bsstyle = GETDICTIONARY(pdfedict,constKEY_BS)
+  local a =""
+  if bsstyle then
+    local bsstyledict = DICTIONARYTOTABLE(bsstyle)
+    a = strKV_BEG .. constKEY_BS .. strVALUE_BEG ..strDICT_BEG
+    for k,v in pairs (bsstyledict) do
+      a = a .. strNAME.. k
+      if v[1]== 5 then
+       a = a .. strNAME .. v[2]
+      else
+       a = a ..strRECT_SEP .. v[2]
+      end
+    end
+    a = a .. strDICT_END .. strVALUE_END .. strKV_END
+  end
+  return a
+end
+
+
+local function outputKV_uri (pdfedict)
+  local type, value, hex = GETFROMDICTIONARY(pdfedict,constKEY_URI)
+  local a= strKV_BEG .. constKEY_URI .. strVALUE_BEG
+  if hex then
+    a = a .. strHEX_STR_BEG .. value .. strHEX_STR_END
+  else
+    a = a .. strLIT_STR_BEG ..value .. strLIT_STR_END
+  end
+    a = a .. strVALUE_END .. strKV_END
+  return a
+end
+
+local function outputKV_N (pdfedict)
+  local name = GETNAME(pdfedict,"N")
+  local a= strKV_BEG .. constKEY_NAME .. strVALUE_BEG .. name .. strVALUE_END .. strKV_END
+  return a
+end
+
+local function outputKV_gotor (pdfedict) -- action dictionary
+  local type, value, hex = GETFROMDICTIONARY(pdfedict,"F")
+  local desttype, destvalue, destdetail =  GETFROMDICTIONARY(pdfedict,"D")
+  local a = strKV_BEG .. constKEY_FILE .. strVALUE_BEG
+  a =  strKV_BEG .. constKEY_FILE .. strVALUE_BEG
+  if hex then
+    a = a .. strHEX_STR_BEG .. value .. strHEX_STR_end
+  else
+    a = a .. strLIT_STR_BEG .. value .. strLIT_STR_END
+  end
+  a = a .. strVALUE_END .. strKV_END
+  if desttype == 7 then
+    local type, pagenum    = GETFROMARRAY(GETARRAY (pdfedict,"D"),1)
+    local type, fittype    = GETFROMARRAY(GETARRAY (pdfedict,"D"),2)
+    a = a .. strKV_BEG .. constKEY_DEST_PAGE .. strVALUE_BEG .. pagenum .. strVALUE_END .. strKV_END
+    a = a .. strKV_BEG .. constKEY_DEST_VIEW .. strVALUE_BEG .. strNAME .. fittype .. strVALUE_END .. strKV_END
+  elseif desttype == 6 then
+   a = a .. strKV_BEG .. constKEY_DEST_NAME .. strVALUE_BEG ..
+          strLIT_STR_BEG .. destvalue .. strLIT_STR_END .. strVALUE_END .. strKV_END
+  end
+  return a
+end
+
+
+local function outputKV_goto (count)
+  local a = strKV_BEG .. constKEY_DEST_LABEL .. strVALUE_BEG .. count .. strVALUE_END .. strKV_END
+  return a
+end
+
+local function outputENTRY_dest (destcount,name,pagereftonum,destnamestoref,pdfedoc)
+ local pagenum, data = getdestdata(name,pagereftonum,destnamestoref)
+ local mediabox = pdfe.getbox(GETPAGE(pdfedoc,pagenum),"MediaBox")
+ local a = strENTRY_BEG
+ a = a .. strCMD_BEG .. constCMD_DEST .. strCMD_END
+ a = a .. strARG_BEG .. pagenum .. strARG_END
+ a = a .. strARG_BEG .. destcount .. strARG_END
+ -- name
+ a = a .. strARG_BEG .. data[2][2] .. strARG_END
+ a = a .. strKVS_BEG
+ if data[2][2] == constDEST_XYZ then
+   if data[3][2] then
+    a = a .. strKV_BEG .. constKEY_DEST_X .. strVALUE_BEG .. data[3][2] .. strVALUE_END .. strKV_END
+   else
+    a = a .. strKV_BEG .. constKEY_DEST_X .. strVALUE_BEG .. mediabox[1] .. strVALUE_END .. strKV_END
+   end
+   if data[4][2] then
+    a = a .. strKV_BEG .. constKEY_DEST_Y .. strVALUE_BEG .. data[4][2] .. strVALUE_END .. strKV_END
+   else
+    a = a .. strKV_BEG .. constKEY_DEST_X .. strVALUE_BEG .. mediabox[4] .. strVALUE_END .. strKV_END
+   end
+   if data[5][2] then
+    a = a .. strKV_BEG .. constKEY_DEST_ZOOM .. strVALUE_BEG .. data[5][2] .. strVALUE_END .. strKV_END
+   end
+ elseif data[2][2] == constDEST_FIT  then -- nothing to do
+ elseif data[2][2] == constDEST_FITB then -- nothing to do
+ elseif data[2][2] == constDEST_FITH then
+   if data[3][2] then
+    a = a .. strKV_BEG .. constKEY_DEST_Y .. strVALUE_BEG .. data[3][2] .. strVALUE_END .. strKV_END
+   end
+ elseif data[2][2] == constDEST_FITBH then
+   if data[3][2] then
+    a = a .. strKV_BEG .. constKEY_DEST_Y .. strVALUE_BEG  .. data[3][2] .. strVALUE_END .. strKV_END
+   end
+ elseif data[2][2] == constDEST_FITV then
+   if data[3][2] then
+    a = a .. strKV_BEG .. constKEY_DEST_X .. strVALUE_BEG .. data[3][2] .. strVALUE_END .. strKV_END
+   end
+ elseif data[2][2] == constDEST_FITBV then
+   if data[3][2] then
+    a = a .. strKV_BEG .. constKEY_DEST_X .. strVALUE_BEG .. data[3][2] .. strVALUE_END .. strKV_END
+   end
+ elseif data[2][2] == constDEST_FITR and data[6] then
+   a = a ..  strKV_BEG .. constKEY_DEST_RECT .. strVALUE_BEG
+   a = a .. data[3][2] .. strRECT_SEP
+   a = a .. data[4][2] .. strRECT_SEP
+   a = a .. data[5][2] .. strRECT_SEP
+   a = a .. data[6][2] .. strVALUE_END .. strKV_END
+ end
+ a = a .. strKVS_END .. strENTRY_END
+ return a
+end
+
+
+
+
+
+
+-- the main function
+
+local function __writepax (ext,file)
+  local fileVAR     = assert(kpse.find_file(file ..".pdf"),"file `"..file..".pdf` not found")
+  local filebaseVAR = FILENAMEONLY(fileVAR)
+  -- getting the data for the concrete document:
+  local writeVAR = io.open (filebaseVAR .."."..ext,"w") -- always in current directory
+  local function WRITE(content)
+    writeVAR:write(content)
+  end
+  local docVAR   = OPEN (fileVAR)
+  local pagereftonumVAR, pagecountVAR = getpagesdata (docVAR)
+  local destcountVAR   = 0
+  -- build from names table:
+  local destnamestorefVAR = getdestreferences (docVAR)
+  local collected_destinations = {}
+  -- output ...
+  WRITE(strENTRY_BEG .. "{pax}{0.1l}" .. strENTRY_END)
+  WRITE(outputENTRY_file(fileVAR,docVAR))
+  WRITE(outputENTRY_pagenum(pagecountVAR))
+  for i=1, pagecountVAR do
+    WRITE(outputENTRY_page(docVAR,i))
+    local annots=GETPAGE(docVAR,i).Annots
+    if annots then
+      for j = 0,#annots-1 do
+        local annot = GETDICTIONARY (annots,j)
+        annottable = DICTIONARYTOTABLE (annot)
+        if annottable.Dest then
+          destcountVAR=destcountVAR + 1
+          WRITE (strENTRY_BEG)
+          WRITE (outputCMD_annot(annot,i,"GoTo"))
+          WRITE (strKVS_BEG) -- begin KVS data
+          WRITE ( outputKV_color(annot) )
+          WRITE ( outputKV_key(annot,constKEY_H) )
+          WRITE ( outputKV_Border (annot) )
+          WRITE ( outputKV_BS (annot) )
+          WRITE ( outputKV_goto (destcountVAR) )
+          WRITE(strKVS_END)   -- end KVS
+          WRITE(strENTRY_END) -- end annot data
+          local type,annotgoto,hex = GETFROMDICTIONARY(annot,"Dest")
+          table.insert(collected_destinations, outputENTRY_dest(destcountVAR,
+               annotgoto,pagereftonumVAR,destnamestorefVAR,docVAR))
+        else
+          local annotaction = GETDICTIONARY(annot,"A")
+          local annotactiontype =""
+          if annotaction then
+            annotactiontype = GETNAME(annotaction,"S")
+            WRITE (strENTRY_BEG)
+            WRITE (outputCMD_annot(annot,i,annotactiontype))
+            WRITE (strKVS_BEG) -- begin KVS data
+            WRITE ( outputKV_color(annot) )
+            WRITE ( outputKV_key(annot,constKEY_H) )
+            WRITE ( outputKV_Border (annot) )
+            WRITE ( outputKV_BS (annot) )
+            if annotactiontype == constKEY_URI then
+              WRITE ( outputKV_uri(annotaction) )
+            elseif annotactiontype =="GoTo" then
+              destcountVAR=destcountVAR + 1
+              WRITE ( outputKV_goto (destcountVAR) )
+            elseif annotactiontype=="GoToR" then
+              WRITE ( outputKV_gotor(annotaction) )
+            elseif annotactiontype=="Named" then
+              WRITE ( outputKV_N (annotaction) )
+            end
+            WRITE(strKVS_END)   -- end KVS
+            WRITE(strENTRY_END) -- end annot data
+            if annotactiontype =="GoTo" then
+              local type,annotactiongoto,hex = GETFROMDICTIONARY(annotaction,"D")
+              table.insert(collected_destinations, outputENTRY_dest(destcountVAR,annotactiongoto,pagereftonumVAR,destnamestorefVAR,docVAR))
+            end
+          end
+        end
+      end
+    end
+  end
+  for i=1,#collected_destinations do
+   WRITE (collected_destinations[i])
+  end
+  io.close(writeVAR)
+end
+
+local function writepax (file)
+ __writepax ("pax",file)
+end
+
+local function writenewpax (file)
+ __writepax ("newpax",file)
+end
+
+newpax = {}
+newpax.writepax    = writepax
+newpax.writenewpax = writenewpax
+
+return newpax
+
+%</lua>
+%    \end{macrocode}


Property changes on: branches/branch2020.0/Master/texmf-dist/source/latex/newpax/newpax.dtx
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: branches/branch2020.0/Master/texmf-dist/source/latex/newpax/newpax.ins
===================================================================
--- branches/branch2020.0/Master/texmf-dist/source/latex/newpax/newpax.ins	                        (rev 0)
+++ branches/branch2020.0/Master/texmf-dist/source/latex/newpax/newpax.ins	2021-03-07 22:06:31 UTC (rev 58203)
@@ -0,0 +1,68 @@
+\iffalse meta-comment
+
+File: newpax.ins
+
+Copyright (C) 2021 Ulrike Fischer
+
+It may be distributed and/or modified under the conditions of the
+LaTeX Project Public License (LPPL), either version 1.3c of this
+license or (at your option) any later version.  The latest version
+of this license is in the file
+
+   https://www.latex-project.org/lppl.txt
+
+This file is part of the "newpax bundle" (The Work in LPPL)
+and all files in that bundle must be distributed together.
+
+The released version of this bundle is available from CTAN.
+
+-----------------------------------------------------------------------
+
+The development version of the bundle can be found at
+
+   https://github.com/u-fischer/newpax
+
+for those people who are interested.
+
+-----------------------------------------------------------------------
+
+\fi
+
+\input l3docstrip.tex
+\askforoverwritefalse
+
+\let\MetaPrefix\relax
+\preamble
+
+Copyright (C) 2021 Ulrike Fischer
+
+It may be distributed and/or modified under the conditions of
+the LaTeX Project Public License (LPPL), either version 1.3c of
+this license or (at your option) any later version.  The latest
+version of this license is in the file:
+
+   https://www.latex-project.org/lppl.txt
+
+This file is part of the "newpax bundle" (The Work in LPPL)
+and all files in that bundle must be distributed together.
+
+\endpreamble
+\let\MetaPrefix\DoubleperCent
+% stop docstrip adding \endinput
+\postamble
+\endpostamble
+
+\keepsilent
+
+\generate
+  {\file{newpax.sty}           {\from{newpax.dtx}{package}}}
+
+
+\def\MetaPrefix{-- }
+\def\defaultpostamble{%
+  \MetaPrefix^^J%
+  \MetaPrefix\space End of File `\outFileName'.%
+}
+\def\currentpostamble{\defaultpostamble}%
+\generate{\file{newpax.lua}   {\from{newpax.dtx}{lua}}}
+\endbatchfile

Added: branches/branch2020.0/Master/texmf-dist/tex/latex/newpax/newpax.lua
===================================================================
--- branches/branch2020.0/Master/texmf-dist/tex/latex/newpax/newpax.lua	                        (rev 0)
+++ branches/branch2020.0/Master/texmf-dist/tex/latex/newpax/newpax.lua	2021-03-07 22:06:31 UTC (rev 58203)
@@ -0,0 +1,521 @@
+-- 
+--  This is file `newpax.lua',
+--  generated with the docstrip utility.
+-- 
+--  The original source files were:
+-- 
+--  newpax.dtx  (with options: `lua')
+--  
+--  Copyright (C) 2021 Ulrike Fischer
+--  
+--  It may be distributed and/or modified under the conditions of
+--  the LaTeX Project Public License (LPPL), either version 1.3c of
+--  this license or (at your option) any later version.  The latest
+--  version of this license is in the file:
+--  
+--     https://www.latex-project.org/lppl.txt
+--  
+--  This file is part of the "newpax bundle" (The Work in LPPL)
+--  and all files in that bundle must be distributed together.
+--  
+local ProvidesLuaModule = {
+    name          = "newpax",
+    version       = "0.51",       --TAGVERSION
+    date          = "2021-03-07", --TAGDATE
+    description   = "newpax lua code",
+    license       = "The LATEX Project Public License 1.3c"
+}
+
+if luatexbase and luatexbase.provides_module then
+  luatexbase.provides_module (ProvidesLuaModule)
+end
+
+local OPEN              = pdfe.open
+local GETSIZE           = pdfe.getsize
+local GETINFO           = pdfe.getinfo
+local GETPAGE           = pdfe.getpage
+local GETNAME           = pdfe.getname
+local GETARRAY          = pdfe.getarray
+local GETDICTIONARY     = pdfe.getdictionary
+local GETFROMDICTIONARY = pdfe.getfromdictionary
+local GETFROMARRAY      = pdfe.getfromarray
+local PAGESTOTABLE      = pdfe.pagestotable
+local DICTIONARYTOTABLE = pdfe.dictionarytotable
+local ARRAYTOTABLE      = pdfe.arraytotable
+local TYPE              = pdfe.type
+local GETFROMREFERENCE  = pdfe.getfromreference
+local FILENAMEONLY      = file.nameonly
+
+local strENTRY_BEG = "\\["
+local strENTRY_END = "\\\\\n"
+local strCMD_BEG = "{"
+local strCMD_END = "}"
+local strARG_BEG = "{"
+local strARG_END = "}"
+local strKVS_BEG = "{"
+local strKVS_END = "\n}"
+local strKVS_EMPTY = "{}"
+local strKV_BEG  = "\n  "
+local strKV_END  = ","
+local strKEY_BEG = ""
+local strKEY_END = ""
+local strVALUE_BEG = "={"
+local strVALUE_END = "}"
+local strHEX_STR_BEG = "\\<"
+local strHEX_STR_END = "\\>"
+
+local strLIT_STR_BEG = "("
+local strLIT_STR_END = ")"
+local strDICT_BEG= "<<"
+local strDICT_END= ">>"
+local strNAME= "/"
+local strARRAY_BEG= "["
+local strARRAY_END= "]"
+local strARRAY_SEP = " "
+local strRECT_SEP = " "
+
+local constCMD_ANNOT   = "annot"
+local constCMD_BASEURL = "baseurl" -- unused
+local constCMD_DEST    = "dest"
+local constCMD_FILE    = "file"
+local constCMD_INFO    = "info"   -- unused
+local constCMD_PAGENUM = "pagenum"
+local constCMD_PAGE    = "page"
+local constCMD_PAX     = "pax"
+
+-- cmd file
+local constKEY_SIZE    = "Size"
+local constKEY_DATE    = "Date"
+
+-- cmd annot attributes
+local constKEY_C      = "C"
+local constKEY_BORDER = "Border"
+local constKEY_BS     = "BS"
+local constKEY_H      = "H"
+
+-- cmd annot/link/URI
+local constKEY_URI    = "URI"
+local constKEY_IS_MAP = "IsMap" -- not handled by pax, consider later
+
+-- cmd annot/link/GoToR
+local constKEY_FILE      = "File"
+local constKEY_DEST_NAME = "DestName" -- handle??
+local constKEY_DEST_PAGE = "DestPage" --ok
+local constKEY_DEST_VIEW = "DestView" --ok
+
+-- cmd annot/link/GoTo
+local constKEY_DEST_RECT  = "DestRect"
+local constKEY_DEST_X     = "DestX"
+local constKEY_DEST_Y     = "DestY"
+local constKEY_DEST_ZOOM  = "DestZoom"
+local constKEY_DEST_LABEL = "DestLabel" --ok
+
+-- cmd annot/link/Named
+local constKEY_NAME = "Name"
+
+-- destination views
+local constDEST_XYZ = "XYZ"
+local constDEST_FIT    = "Fit"
+local constDEST_FITH   = "FitH"
+local constDEST_FITV   = "FitV"
+local constDEST_FITR   = "FitR"
+local constDEST_FITB   = "FitB"
+local constDEST_FITBH  = "FitBH"
+local constDEST_FITBV  = "FitBV"
+
+-- get/build data
+-- returns table,pagecount where table objref ->page number
+local function getpagesdata (pdfedoc)
+  local type,pagecount,detail   = GETFROMDICTIONARY (pdfedoc.Catalog.Pages,"Count")
+  local pagestable  = PAGESTOTABLE (pdfedoc)
+  local pagereftonum ={}
+  for i=1,#pagestable do
+   pagereftonum[pagestable[i][3]]=i
+  end
+  return pagereftonum, pagecount
+end
+
+-- builds a table destination name -> obj reference (pdfedict) from the Names tree
+
+local function processnamesarray (pdfearray,targettable)
+  local tkey={}
+  for i=1,#pdfearray do
+    local type,value,detail= GETFROMARRAY(pdfearray,i)
+    if (i % 2 == 1) then
+     tkey = value
+    else
+      tvalue = value
+      targettable[tkey]=tvalue
+    end
+  end
+end
+
+local function findallnamesarrays (pdfedict,deststable)
+  local namesarray  = GETARRAY(pdfedict,"Names")
+  if namesarray then
+     processnamesarray (namesarray,deststable)
+  else
+     local kidsarray = GETARRAY(pdfedict,"Kids")
+     if kidsarray then
+       for i=1,#kidsarray do
+         findallnamesarrays (kidsarray[i],deststable)
+       end
+     end
+  end
+end
+
+-- returns destnames -> objref table
+local function getdestreferences (pdfedoc)
+  local deststable= {}
+  local catnames  = GETDICTIONARY (pdfedoc.Catalog, "Names")
+  if catnames then
+    local destsdict = GETDICTIONARY (catnames, "Dests")
+    if destsdict then
+      findallnamesarrays (destsdict,deststable)
+    end
+  end
+  return deststable
+end
+
+-- destinations can be an dict (/D [array]) or only an array!
+
+local function getdestdata (name,pagereftonum,destnamestoref)
+   local destref = destnamestoref[name]
+   local type,ref,pagenum,destx,desty = nil, nil, 1,0,0
+   local data = {{0,0}, {5,constDEST_XYZ}}
+   if destref then
+     type,value,detail = GETFROMREFERENCE(destref)
+     if TYPE(value) == "pdfe.dictionary" then
+       local destarray = GETARRAY(value,"D")
+       if destarray then
+         data = ARRAYTOTABLE(destarray)
+         type, ref, pageref = GETFROMARRAY(destarray,1)
+         pagenum = pagereftonum[pageref]
+       end
+     elseif TYPE(value) == "pdfe.array" then
+        data = ARRAYTOTABLE(value)
+        type, ref, pageref = GETFROMARRAY(value,1)
+        pagenum = pagereftonum[pageref]
+     end
+   end
+  return pagenum, data
+end
+
+-- output functions
+-- write the info
+-- XXXXXX encode/escape the file name?
+local function outputENTRY_file (file, pdfedoc)
+  local bytes       = GETSIZE(pdfedoc)
+  local date        = GETINFO(pdfedoc).CreationDate
+  -- file
+  local a = strENTRY_BEG
+  a = a .. strCMD_BEG .. constCMD_FILE .. strCMD_END
+  a = a .. strARG_BEG .. strLIT_STR_BEG .. file .. strLIT_STR_END ..  strARG_END
+  a = a .. strKVS_BEG
+   a = a .. strKV_BEG .. constKEY_SIZE .. strVALUE_BEG .. bytes .. strVALUE_END .. strKV_END
+   a = a .. strKV_BEG .. constKEY_DATE .. strVALUE_BEG .. date .. strVALUE_END.. strKV_END
+  a = a .. strKVS_END
+  a = a .. strENTRY_END
+  return a
+end
+
+local function outputENTRY_pagenum (pages)
+  local a = strENTRY_BEG
+  a = a .. strCMD_BEG .. constCMD_PAGENUM .. strCMD_END
+  a = a .. strARG_BEG .. pages .. strARG_END
+  a = a .. strENTRY_END
+  return a
+end
+
+local function outputENTRY_page (pdfedoc,page) -- page=integer
+  -- trimbox, bleedbox, cropbox,artbox,rotate etc could be put in
+  -- the second argument as keyval:
+  -- TrimBox={0 0 300 350},
+  -- but pax skips the argument anyway, so not really useful
+  local mediabox = pdfe.getbox(GETPAGE(pdfedoc,page),"MediaBox")
+  local a=""
+  if mediabox then
+    a = strENTRY_BEG
+    a = a .. strCMD_BEG .. constCMD_PAGE .. strCMD_END
+    a = a .. strARG_BEG .. page .. strARG_END
+    a = a .. strARG_BEG
+      a = a .. mediabox[1]
+      for j = 2, 4 do
+       a = a .. strRECT_SEP.. mediabox[j]
+      end
+    a = a .. strARG_END
+    a = a .. strKVS_EMPTY
+    a = a .. strENTRY_END
+  end
+  return a
+end
+
+local function outputCMD_annot (pdfedict,page,type)
+  local rectangle = ARRAYTOTABLE(GETARRAY(pdfedict,"Rect"))
+  local a = strCMD_BEG .. constCMD_ANNOT .. strCMD_END
+      a = a .. strARG_BEG .. page .. strARG_END
+      a = a .. strARG_BEG .. GETNAME(pdfedict,"Subtype") .. strARG_END
+      a = a .. strARG_BEG
+       a = a .. rectangle[1][2]
+        for k = 2, 4 do
+         a = a.. strRECT_SEP..rectangle[k][2]
+        end
+      a = a .. strARG_END
+      a = a .. strARG_BEG .. type .. strARG_END
+  return a
+end
+
+local function outputKV_color (pdfedict)
+  local color = GETARRAY(pdfedict,constKEY_C)
+  local a =""
+  if color then
+    local colortable = ARRAYTOTABLE(color)
+    a = strKV_BEG .. constKEY_C .. strVALUE_BEG .. strARRAY_BEG
+      for i=1,#colortable do
+        a = a.. colortable[i][2] .. strARRAY_SEP
+      end
+    a = a .. strARRAY_END .. strVALUE_END .. strKV_END
+  end
+  return a
+end
+
+local function outputKV_key (pdfedict,key)
+  local name = GETNAME(pdfedict,key)
+  local a = ""
+  if name then
+    a = strKV_BEG .. key .. strVALUE_BEG .. strNAME .. name .. strVALUE_END .. strKV_END
+  end
+  return a
+end
+
+-- XXX handle fourth argument
+local function outputKV_Border (pdfedict)
+  local border = GETARRAY(pdfedict,constKEY_BORDER)
+  local a =""
+  if border then
+    local bordertable = ARRAYTOTABLE(border)
+    a = strKV_BEG .. constKEY_BORDER .. strVALUE_BEG .. strARRAY_BEG
+    for i=1,3 do
+      a = a .. bordertable[i][2] .. strARRAY_SEP
+    end
+ -- fourth argument later, it is an array (type 7)
+   a = a ..strARRAY_END .. strVALUE_END .. strKV_END
+  end
+  return a
+end
+
+local function outputKV_BS (pdfedict)
+  local bsstyle = GETDICTIONARY(pdfedict,constKEY_BS)
+  local a =""
+  if bsstyle then
+    local bsstyledict = DICTIONARYTOTABLE(bsstyle)
+    a = strKV_BEG .. constKEY_BS .. strVALUE_BEG ..strDICT_BEG
+    for k,v in pairs (bsstyledict) do
+      a = a .. strNAME.. k
+      if v[1]== 5 then
+       a = a .. strNAME .. v[2]
+      else
+       a = a ..strRECT_SEP .. v[2]
+      end
+    end
+    a = a .. strDICT_END .. strVALUE_END .. strKV_END
+  end
+  return a
+end
+
+local function outputKV_uri (pdfedict)
+  local type, value, hex = GETFROMDICTIONARY(pdfedict,constKEY_URI)
+  local a= strKV_BEG .. constKEY_URI .. strVALUE_BEG
+  if hex then
+    a = a .. strHEX_STR_BEG .. value .. strHEX_STR_END
+  else
+    a = a .. strLIT_STR_BEG ..value .. strLIT_STR_END
+  end
+    a = a .. strVALUE_END .. strKV_END
+  return a
+end
+
+local function outputKV_N (pdfedict)
+  local name = GETNAME(pdfedict,"N")
+  local a= strKV_BEG .. constKEY_NAME .. strVALUE_BEG .. name .. strVALUE_END .. strKV_END
+  return a
+end
+
+local function outputKV_gotor (pdfedict) -- action dictionary
+  local type, value, hex = GETFROMDICTIONARY(pdfedict,"F")
+  local desttype, destvalue, destdetail =  GETFROMDICTIONARY(pdfedict,"D")
+  local a = strKV_BEG .. constKEY_FILE .. strVALUE_BEG
+  a =  strKV_BEG .. constKEY_FILE .. strVALUE_BEG
+  if hex then
+    a = a .. strHEX_STR_BEG .. value .. strHEX_STR_end
+  else
+    a = a .. strLIT_STR_BEG .. value .. strLIT_STR_END
+  end
+  a = a .. strVALUE_END .. strKV_END
+  if desttype == 7 then
+    local type, pagenum    = GETFROMARRAY(GETARRAY (pdfedict,"D"),1)
+    local type, fittype    = GETFROMARRAY(GETARRAY (pdfedict,"D"),2)
+    a = a .. strKV_BEG .. constKEY_DEST_PAGE .. strVALUE_BEG .. pagenum .. strVALUE_END .. strKV_END
+    a = a .. strKV_BEG .. constKEY_DEST_VIEW .. strVALUE_BEG .. strNAME .. fittype .. strVALUE_END .. strKV_END
+  elseif desttype == 6 then
+   a = a .. strKV_BEG .. constKEY_DEST_NAME .. strVALUE_BEG ..
+          strLIT_STR_BEG .. destvalue .. strLIT_STR_END .. strVALUE_END .. strKV_END
+  end
+  return a
+end
+
+local function outputKV_goto (count)
+  local a = strKV_BEG .. constKEY_DEST_LABEL .. strVALUE_BEG .. count .. strVALUE_END .. strKV_END
+  return a
+end
+
+local function outputENTRY_dest (destcount,name,pagereftonum,destnamestoref,pdfedoc)
+ local pagenum, data = getdestdata(name,pagereftonum,destnamestoref)
+ local mediabox = pdfe.getbox(GETPAGE(pdfedoc,pagenum),"MediaBox")
+ local a = strENTRY_BEG
+ a = a .. strCMD_BEG .. constCMD_DEST .. strCMD_END
+ a = a .. strARG_BEG .. pagenum .. strARG_END
+ a = a .. strARG_BEG .. destcount .. strARG_END
+ -- name
+ a = a .. strARG_BEG .. data[2][2] .. strARG_END
+ a = a .. strKVS_BEG
+ if data[2][2] == constDEST_XYZ then
+   if data[3][2] then
+    a = a .. strKV_BEG .. constKEY_DEST_X .. strVALUE_BEG .. data[3][2] .. strVALUE_END .. strKV_END
+   else
+    a = a .. strKV_BEG .. constKEY_DEST_X .. strVALUE_BEG .. mediabox[1] .. strVALUE_END .. strKV_END
+   end
+   if data[4][2] then
+    a = a .. strKV_BEG .. constKEY_DEST_Y .. strVALUE_BEG .. data[4][2] .. strVALUE_END .. strKV_END
+   else
+    a = a .. strKV_BEG .. constKEY_DEST_X .. strVALUE_BEG .. mediabox[4] .. strVALUE_END .. strKV_END
+   end
+   if data[5][2] then
+    a = a .. strKV_BEG .. constKEY_DEST_ZOOM .. strVALUE_BEG .. data[5][2] .. strVALUE_END .. strKV_END
+   end
+ elseif data[2][2] == constDEST_FIT  then -- nothing to do
+ elseif data[2][2] == constDEST_FITB then -- nothing to do
+ elseif data[2][2] == constDEST_FITH then
+   if data[3][2] then
+    a = a .. strKV_BEG .. constKEY_DEST_Y .. strVALUE_BEG .. data[3][2] .. strVALUE_END .. strKV_END
+   end
+ elseif data[2][2] == constDEST_FITBH then
+   if data[3][2] then
+    a = a .. strKV_BEG .. constKEY_DEST_Y .. strVALUE_BEG  .. data[3][2] .. strVALUE_END .. strKV_END
+   end
+ elseif data[2][2] == constDEST_FITV then
+   if data[3][2] then
+    a = a .. strKV_BEG .. constKEY_DEST_X .. strVALUE_BEG .. data[3][2] .. strVALUE_END .. strKV_END
+   end
+ elseif data[2][2] == constDEST_FITBV then
+   if data[3][2] then
+    a = a .. strKV_BEG .. constKEY_DEST_X .. strVALUE_BEG .. data[3][2] .. strVALUE_END .. strKV_END
+   end
+ elseif data[2][2] == constDEST_FITR and data[6] then
+   a = a ..  strKV_BEG .. constKEY_DEST_RECT .. strVALUE_BEG
+   a = a .. data[3][2] .. strRECT_SEP
+   a = a .. data[4][2] .. strRECT_SEP
+   a = a .. data[5][2] .. strRECT_SEP
+   a = a .. data[6][2] .. strVALUE_END .. strKV_END
+ end
+ a = a .. strKVS_END .. strENTRY_END
+ return a
+end
+
+-- the main function
+
+local function __writepax (ext,file)
+  local fileVAR     = assert(kpse.find_file(file ..".pdf"),"file `"..file..".pdf` not found")
+  local filebaseVAR = FILENAMEONLY(fileVAR)
+  -- getting the data for the concrete document:
+  local writeVAR = io.open (filebaseVAR .."."..ext,"w") -- always in current directory
+  local function WRITE(content)
+    writeVAR:write(content)
+  end
+  local docVAR   = OPEN (fileVAR)
+  local pagereftonumVAR, pagecountVAR = getpagesdata (docVAR)
+  local destcountVAR   = 0
+  -- build from names table:
+  local destnamestorefVAR = getdestreferences (docVAR)
+  local collected_destinations = {}
+  -- output ...
+  WRITE(strENTRY_BEG .. "{pax}{0.1l}" .. strENTRY_END)
+  WRITE(outputENTRY_file(fileVAR,docVAR))
+  WRITE(outputENTRY_pagenum(pagecountVAR))
+  for i=1, pagecountVAR do
+    WRITE(outputENTRY_page(docVAR,i))
+    local annots=GETPAGE(docVAR,i).Annots
+    if annots then
+      for j = 0,#annots-1 do
+        local annot = GETDICTIONARY (annots,j)
+        annottable = DICTIONARYTOTABLE (annot)
+        if annottable.Dest then
+          destcountVAR=destcountVAR + 1
+          WRITE (strENTRY_BEG)
+          WRITE (outputCMD_annot(annot,i,"GoTo"))
+          WRITE (strKVS_BEG) -- begin KVS data
+          WRITE ( outputKV_color(annot) )
+          WRITE ( outputKV_key(annot,constKEY_H) )
+          WRITE ( outputKV_Border (annot) )
+          WRITE ( outputKV_BS (annot) )
+          WRITE ( outputKV_goto (destcountVAR) )
+          WRITE(strKVS_END)   -- end KVS
+          WRITE(strENTRY_END) -- end annot data
+          local type,annotgoto,hex = GETFROMDICTIONARY(annot,"Dest")
+          table.insert(collected_destinations, outputENTRY_dest(destcountVAR,
+               annotgoto,pagereftonumVAR,destnamestorefVAR,docVAR))
+        else
+          local annotaction = GETDICTIONARY(annot,"A")
+          local annotactiontype =""
+          if annotaction then
+            annotactiontype = GETNAME(annotaction,"S")
+            WRITE (strENTRY_BEG)
+            WRITE (outputCMD_annot(annot,i,annotactiontype))
+            WRITE (strKVS_BEG) -- begin KVS data
+            WRITE ( outputKV_color(annot) )
+            WRITE ( outputKV_key(annot,constKEY_H) )
+            WRITE ( outputKV_Border (annot) )
+            WRITE ( outputKV_BS (annot) )
+            if annotactiontype == constKEY_URI then
+              WRITE ( outputKV_uri(annotaction) )
+            elseif annotactiontype =="GoTo" then
+              destcountVAR=destcountVAR + 1
+              WRITE ( outputKV_goto (destcountVAR) )
+            elseif annotactiontype=="GoToR" then
+              WRITE ( outputKV_gotor(annotaction) )
+            elseif annotactiontype=="Named" then
+              WRITE ( outputKV_N (annotaction) )
+            end
+            WRITE(strKVS_END)   -- end KVS
+            WRITE(strENTRY_END) -- end annot data
+            if annotactiontype =="GoTo" then
+              local type,annotactiongoto,hex = GETFROMDICTIONARY(annotaction,"D")
+              table.insert(collected_destinations, outputENTRY_dest(destcountVAR,annotactiongoto,pagereftonumVAR,destnamestorefVAR,docVAR))
+            end
+          end
+        end
+      end
+    end
+  end
+  for i=1,#collected_destinations do
+   WRITE (collected_destinations[i])
+  end
+  io.close(writeVAR)
+end
+
+local function writepax (file)
+ __writepax ("pax",file)
+end
+
+local function writenewpax (file)
+ __writepax ("newpax",file)
+end
+
+newpax = {}
+newpax.writepax    = writepax
+newpax.writenewpax = writenewpax
+
+return newpax
+
+-- 
+--  End of File `newpax.lua'.


Property changes on: branches/branch2020.0/Master/texmf-dist/tex/latex/newpax/newpax.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: branches/branch2020.0/Master/texmf-dist/tex/latex/newpax/newpax.sty
===================================================================
--- branches/branch2020.0/Master/texmf-dist/tex/latex/newpax/newpax.sty	                        (rev 0)
+++ branches/branch2020.0/Master/texmf-dist/tex/latex/newpax/newpax.sty	2021-03-07 22:06:31 UTC (rev 58203)
@@ -0,0 +1,677 @@
+%%
+%% This is file `newpax.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% newpax.dtx  (with options: `package')
+%% 
+%% Copyright (C) 2021 Ulrike Fischer
+%% 
+%% It may be distributed and/or modified under the conditions of
+%% the LaTeX Project Public License (LPPL), either version 1.3c of
+%% this license or (at your option) any later version.  The latest
+%% version of this license is in the file:
+%% 
+%%    https://www.latex-project.org/lppl.txt
+%% 
+%% This file is part of the "newpax bundle" (The Work in LPPL)
+%% and all files in that bundle must be distributed together.
+%% 
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{newpax}%
+  [2021-03-07 v0.51 Annotation support for PDF graphics based on pax.sty adapted by (UF)]%
+\ExplSyntaxOn
+\bool_if:nF
+  {
+    \cs_if_exist_p:N \pdfmanagement_if_active_p:
+  }
+  {  %error for now, perhaps warning later.
+    \PackageError{newpax}
+     {
+       PDF~resource~management~code~not~found!\MessageBreak
+       newpage~will~no~work.
+     }
+     {
+       Load~it~with \MessageBreak
+       \string\RequirePackage{pdfmanagement-testphase}\MessageBreak
+       before~loading~the~class
+     }
+  }
+
+\ExplSyntaxOff
+\RequirePackage{graphicx}
+\RequirePackage{ltxcmds}[2011/04/18]
+\RequirePackage{kvsetkeys}[2011/04/07]
+\RequirePackage{kvoptions}[2010/12/23]
+\RequirePackage{auxhook}[2011/03/04]
+\RequirePackage{etoolbox}
+\RequirePackage{xfp}
+
+\ExplSyntaxOn
+\cs_set_eq:NN \newpax at str@if at eq@@nnT\str_if_eq:nnT
+
+\bool_new:N \l__newpax_use_attributes_bool
+\bool_new:N \l__newpax_addannots_bool
+
+\tl_new:N   \l__newpax_destsuffix_tl
+\tl_new:N \NEWPAX at fileextension
+
+\cs_generate_variant:Nn \pdfannot_dict_put:nnn {nnx,xnx,xnn}
+\NewDocumentCommand\newpaxsetup { m }
+  {
+    \keys_set:nn {newpax}{ #1}
+  }
+
+\keys_define:nn {newpax}
+  {
+    usefileattributes .bool_set:N = \l__newpax_use_attributes_bool,
+    destsuffix        .tl_set:N   = \l__newpax_destsuffix_tl,
+    addannots         .bool_set:N = \l__newpax_addannots_bool,
+    addannots         .default:n  = true,
+    addannots         .initial:n  = true,
+    paxextension      .choices:nn =
+       {pax,newpax}
+       {\tl_set:Nn \NEWPAX at fileextension {#1}},
+    paxextension .initial:n = newpax
+  }
+
+\cs_new_protected:Npn \@NEWPAX at setattributes@n #1 %link type
+  {
+    \bool_if:NT \l__newpax_use_attributes_bool
+      {
+        \tl_if_empty:NTF  \NEWPAX at key@C
+          {
+            \pdfannot_dict_remove:nn {link/#1} { C }
+          }
+          {
+            \pdfannot_dict_put:nnx
+              {link/#1}
+              { C }
+              { \NEWPAX at key@C }
+          }
+        \tl_if_empty:NTF \NEWPAX at key@Border
+          {
+            \pdfannot_dict_remove:nn {link/#1} { Border }
+          }
+          {
+            \pdfannot_dict_put:nnx
+              {link/#1}
+              { Border }
+              { \NEWPAX at key@Border }
+          }
+        \tl_if_empty:NTF \NEWPAX at key@BS
+          {
+            \pdfannot_dict_remove:nn {link/#1} { BS }
+          }
+          {
+            \pdfannot_dict_put:nnx
+              {link/#1}
+              { BS }
+              { \NEWPAX at key@BS }
+          }
+        \tl_if_empty:NTF \NEWPAX at key@H
+          {
+            \pdfannot_dict_remove:nn {link/#1} { H }
+          }
+          {
+            \pdfannot_dict_put:nnx
+              {link/#1}
+              { H }
+              { \NEWPAX at key@H }
+          }
+      }
+  }
+
+\cs_new_protected:Npn \@NEWPAX at linkgoto@xnn #1 #2 #3  %#1 dest #2 width #3 height
+  {
+    \group_begin:
+      \exp_args:Nx\@NEWPAX at setattributes@n {GoTo}
+      \leavevmode
+      \exp_args:Nx\pdfannot_link_goto_begin:nw
+        { #1 }
+        \@NEWPAX at ensurelinkbox@n{\hbox_to_wd:nn {#2}{ { \rule{0pt}{#3} }\hfill}}
+      \pdfannot_link_goto_end:
+    \group_end:
+  }
+
+\cs_new_protected:Npn \@NEWPAX at link@setaction at nn #1 #2
+ {
+    \pdfannot_dict_put:nnn{link/#1}{Subtype}{/Link}
+    \pdfannot_dict_put:nnx{link/#1}{A}
+       {<</Type/Action/S/#1 #2>>}
+ }
+
+\cs_new_protected:Npn \@NEWPAX at annotboxlink@nnn #1 #2 #3   %#1 type, #2 width #3 height
+  {
+    \group_begin:
+      \exp_args:Nx\@NEWPAX at setattributes@n {#1}
+      \leavevmode
+      \pdfannot_box:nnnx {#2}{#3}{0pt}
+         {\pdfannot_dict_use:n{link/#1}}
+    \group_end:
+  }
+
+\cs_new_protected:Npn \@NEWPAX at destination@xx #1 #2
+  {
+    \exp_args:Nxx \pdf_destination:nn {#1}{#2}
+  }
+
+\sys_if_engine_xetex:TF
+  {
+    \cs_set_eq:NN \@NEWPAX at ensurelinkbox@n \XeTeXLinkBox
+  }
+  {
+    \cs_set_eq:NN \@NEWPAX at ensurelinkbox@n \use:n
+  }
+\ExplSyntaxOff
+\let\NEWPAX at ORG@includegraphics\includegraphics
+\def\includegraphics{%
+  \@ifstar{%
+    \@ifnextchar[{%
+      \begingroup
+        \def\x{\endgroup
+           \NEWPAX at includegraphics[clip,%
+        }%
+      \expandafter\x\@gobble
+    }{%
+      \NEWPAX at includegraphics[clip]%
+    }%
+  }{%
+    \@ifnextchar[{%
+      \NEWPAX at includegraphics
+    }{%
+      \NEWPAX at includegraphics[]%
+    }%
+  }%
+}
+
+\ExplSyntaxOn
+\def\NEWPAX at includegraphics[#1]#2{%
+  \begingroup
+    \sbox0{\NEWPAX at ORG@includegraphics[{#1}]{#2}}%
+    \edef\NEWPAX at inc@width{\the\wd0}%
+    \edef\NEWPAX at inc@height{\the\dimexpr\dp0+\ht0}%
+    \leavevmode
+    \hbox to \wd0{%
+      \rlap{\copy0}%
+      \bool_if:nT
+        { \l__newpax_addannots_bool
+           &&
+           (
+            \int_compare_p:nNn
+             {
+               \cs_if_exist:NTF\pdfpages at includegraphics@status
+                 {
+                    \pdfpages at includegraphics@status
+                 }{0}
+             }
+             <
+             {2}
+           )
+        }
+        {
+          \raise-\dp0\hbox
+            {
+              \NEWPAX at AddAnnots{#1}{#2}%
+            }
+        }
+      \hfill
+    }
+  \endgroup
+}
+\ExplSyntaxOff
+\SetupKeyvalOptions{family=NEWPAX at Gin,prefix=NEWPAX at Gin@}
+\DeclareStringOption[1]{page}
+\DeclareStringOption[0]{angle}
+\DeclareBoolOption{clip}
+\define at key{NEWPAX at Gin}{viewport}{%
+  \ltx at LocalAppendToMacro\NEWPAX at Gin@box at opts{%
+    \NEWPAX at viewport#1\\%
+  }%
+}
+\define at key{NEWPAX at Gin}{trim}{%
+  \ltx at LocalAppendToMacro\NEWPAX at Gin@box at opts{%
+    \NEWPAX at trim#1\\%
+  }%
+}
+\let\NEWPAX at Gin@box at opts\@empty
+
+\def\NEWPAX at viewport#1 #2 #3 #4\\{%
+  \NEWPAX at defaultbp\NEWPAX at vllx{#1}%
+  \NEWPAX at defaultbp\NEWPAX at vlly{#2}%
+  \NEWPAX at defaultbp\NEWPAX at vurx{#3}%
+  \NEWPAX at defaultbp\NEWPAX at vury{#4}%
+  \edef\NEWPAX at page@llx{\dimexpr\NEWPAX at page@llx+\NEWPAX at vllx\relax}%
+  \edef\NEWPAX at page@lly{\dimexpr\NEWPAX at page@lly+\NEWPAX at vlly\relax}%
+  \edef\NEWPAX at page@urx{\dimexpr\NEWPAX at page@llx+\NEWPAX at vlly\relax}%
+  \edef\NEWPAX at page@ury{\dimexpr\NEWPAX at page@lly+\NEWPAX at vury\relax}%
+}
+\def\NEWPAX at trim#1 #2 #3 #4\\{%
+  \NEWPAX at defaultbp\NEWPAX at tllx{#1}%
+  \NEWPAX at defaultbp\NEWPAX at tlly{#2}%
+  \NEWPAX at defaultbp\NEWPAX at turx{#3}%
+  \NEWPAX at defaultbp\NEWPAX at tury{#4}%
+  \edef\NEWPAX at page@llx{\dimexpr\NEWPAX at page@llx+\NEWPAX at tllx\relax}%
+  \edef\NEWPAX at page@lly{\dimexpr\NEWPAX at page@lly+\NEWPAX at tlly\relax}%
+  \edef\NEWPAX at page@urx{\dimexpr\NEWPAX at page@urx-\NEWPAX at turx\relax}%
+  \edef\NEWPAX at page@ury{\dimexpr\NEWPAX at page@ury-\NEWPAX at tury\relax}%
+}
+
+\def\NEWPAX at defaultbp#1#2{%
+  \afterassignment\NEWPAX at def@bp\dimen@#2bp\relax{#1}{#2}%
+}
+\def\NEWPAX at def@bp#1\relax#2#3{%
+  \if!#1!%
+    \edef#2{#3bp}%
+  \else
+    \edef#2{#3}%
+  \fi
+}
+
+\kv at set@family at handler{NEWPAX at Gin}{}
+
+\def\NEWPAX at AddAnnots#1#2{%
+  \kvsetkeys{NEWPAX at Gin}{#1}%
+  \Grot at setangle{\NEWPAX at Gin@angle}%
+  % a little careful, is type of angle int or real?
+  \loop
+  \ifdim\NEWPAX at Gin@angle\p@<360\p@
+  \else
+    \edef\NEWPAX at Gin@angle{\the\numexpr-360+\number\NEWPAX at Gin@angle}%
+  \repeat
+  \loop
+  \ifdim\NEWPAX at Gin@angle\p@<\z@
+    \edef\NEWPAX at Gin@angle{\strip at pt\dimexpr\NEWPAX at Gin@angle\p at +360\p@}%
+  \repeat
+  \ifcase0\ifnum\NEWPAX at Gin@angle=0 1\fi
+          \ifnum\NEWPAX at Gin@angle=90 1\fi
+          \ifnum\NEWPAX at Gin@angle=180 1\fi
+          \ifnum\NEWPAX at Gin@angle=270 1\fi
+    \PackageWarning{newpax}{Unsupported value for option angle}%
+  \fi
+  \filename at parse{#2}%
+  \def\NEWPAX at file{%\filename at area
+  \filename at base.\NEWPAX at fileextension }%
+  \let\[\NEWPAX at parser
+  \def\<{<}%
+  \def\>{>}%
+  \endlinechar=-1 %
+  \begingroup
+  \catcode`\#=12 \catcode`\%=12
+  \InputIfFileExists\NEWPAX at file{}{\typeout{* Missing: \NEWPAX at file}}\endgroup
+}
+\def\NEWPAX at parser#1{\NEWPAX at call{cmd}{#1}{}}%
+\def\NEWPAX at call#1#2#3{%
+  \@ifundefined{NEWPAX@#1@#2}\NEWPAX at skip{#3\csname NEWPAX@#1@#2\endcsname}%
+}
+\def\NEWPAX at skip#1\\{}
+\def\NEWPAX at stop#1\\{}
+
+\def\NEWPAX at cmd@page#1#2{%
+  \NEWPAX at filter@page{#1}{%
+    \NEWPAX at getrect{page}#2\@nil
+    \NEWPAX at Gin@box at opts
+    \ifcase0\ifnum\NEWPAX at Gin@angle=90 1\fi
+            \ifnum\NEWPAX at Gin@angle=270 1\fi
+    \else
+      \let\NEWPAX at temp\NEWPAX at inc@width
+      \let\NEWPAX at inc@width\NEWPAX at inc@height
+      \let\NEWPAX at inc@height\NEWPAX at temp
+    \fi
+    \Gscale at div\NEWPAX at scale@x\NEWPAX at inc@width{%
+      \dimexpr\NEWPAX at page@urx-\NEWPAX at page@llx\relax
+    }%
+    \Gscale at div\NEWPAX at scale@y\NEWPAX at inc@height{%
+      \dimexpr\NEWPAX at page@ury-\NEWPAX at page@lly\relax
+    }%
+    \NEWPAX at skip
+  }%
+}
+\def\NEWPAX at filter@page#1{%
+  \ifnum\NEWPAX at Gin@page=#1 %
+    \expandafter\@firstofone
+  \else
+    \ifnum\NEWPAX at Gin@page<#1 %
+      \csname fi\endcsname
+      \csname fi\endcsname
+      \expandafter\NEWPAX at stop\@gobblefour
+    \fi
+    \expandafter\NEWPAX at skip
+  \fi
+}
+\def\NEWPAX at getrect#1#2 #3 #4 #5\@nil{%
+  \@namedef{NEWPAX@#1 at llx}{#2bp}%
+  \@namedef{NEWPAX@#1 at lly}{#3bp}%
+  \@namedef{NEWPAX@#1 at urx}{#4bp}%
+  \@namedef{NEWPAX@#1 at ury}{#5bp}%
+}
+
+\def\NEWPAX at cmd@annot#1#2{%
+  \NEWPAX at filter@page{#1}{%
+    \NEWPAX at call{annot}{#2}{}%
+  }%
+}
+\def\NEWPAX at annot@Link#1#2#3{%
+  \def\NEWPAX at link@type{#2}%
+  \NEWPAX at call{link}{#2}{%
+    \begingroup
+    \NEWPAX at getrect{annot}#1\@nil
+    \kvsetkeys{NEWPAX}{#3}%
+  }%
+  \NEWPAX at skip
+}
+\newif\ifNEWPAX at ok
+\NEWPAX at oktrue
+
+\newif\ifNEWPAX at GoTo
+
+\def\NEWPAX at pdf@annot#1{%
+  \ifNEWPAX at Gin@clip
+    \ifdim\NEWPAX at annot@llx<\NEWPAX at page@llx
+      \let\NEWPAX at annot@llx\NEWPAX at page@llx
+    \fi
+    \ifdim\NEWPAX at annot@lly<\NEWPAX at page@lly
+      \let\NEWPAX at annot@lly\NEWPAX at page@lly
+    \fi
+    \ifdim\NEWPAX at annot@urx>\NEWPAX at page@urx
+      \let\NEWPAX at annot@urx\NEWPAX at page@urx
+    \fi
+    \ifdim\NEWPAX at annot@ury>\NEWPAX at page@ury
+      \let\NEWPAX at annot@ury\NEWPAX at page@ury
+    \fi
+    \NEWPAX at okfalse
+    \ifdim\NEWPAX at annot@llx<\NEWPAX at annot@urx\relax
+      \ifdim\NEWPAX at annot@lly<\NEWPAX at annot@ury\relax
+        \NEWPAX at oktrue
+      \fi
+    \fi
+  \else
+    \NEWPAX at oktrue
+  \fi
+  \ifNEWPAX at ok
+    \ifcase 0\ifnum\NEWPAX at Gin@angle=90 1\fi
+             \ifnum\NEWPAX at Gin@angle=180 2\fi
+             \ifnum\NEWPAX at Gin@angle=270 3\fi\space
+      % angle = 0
+      \def\NEWPAX at raise{%
+        \NEWPAX at scale@y\dimexpr\NEWPAX at annot@lly-\NEWPAX at page@lly\relax
+      }%
+      \def\NEWPAX at right{%
+        \NEWPAX at scale@x\dimexpr\NEWPAX at annot@llx-\NEWPAX at page@llx\relax
+      }%
+    \or % angle = 90
+      \def\NEWPAX at raise{%
+        \NEWPAX at scale@x\dimexpr\NEWPAX at annot@llx-\NEWPAX at page@llx\relax
+      }%
+      \def\NEWPAX at right{%
+        \NEWPAX at scale@y\dimexpr\NEWPAX at page@ury-\NEWPAX at annot@ury\relax
+      }%
+    \or % angle = 180
+      \def\NEWPAX at raise{%
+        \NEWPAX at scale@y\dimexpr\NEWPAX at page@ury-\NEWPAX at annot@ury\relax
+      }%
+      \def\NEWPAX at right{%
+        \NEWPAX at scale@x\dimexpr\NEWPAX at page@urx-\NEWPAX at annot@urx\relax
+      }%
+    \or % angle = 270
+      \def\NEWPAX at raise{%
+        \NEWPAX at scale@x\dimexpr\NEWPAX at page@urx-\NEWPAX at annot@urx\relax
+      }%
+      \def\NEWPAX at right{%
+        \NEWPAX at scale@y\dimexpr\NEWPAX at annot@lly-\NEWPAX at page@lly\relax
+      }%
+    \fi
+    \@namedef{%
+      NEWPAX@%
+      \ifcase0\ifnum\NEWPAX at Gin@angle=90 1\fi
+              \ifnum\NEWPAX at Gin@angle=270 1\fi\space
+        width%
+      \else
+        height%
+      \fi
+    }{%
+      \NEWPAX at scale@x\dimexpr\NEWPAX at annot@urx-\NEWPAX at annot@llx\relax
+    }%
+    \@namedef{%
+      NEWPAX@%
+      \ifcase0\ifnum\NEWPAX at Gin@angle=90 1\fi
+              \ifnum\NEWPAX at Gin@angle=270 1\fi\space
+        height%
+      \else
+        width%
+      \fi
+    }{%
+      \NEWPAX at scale@y\dimexpr\NEWPAX at annot@ury-\NEWPAX at annot@lly\relax
+    }%
+    \raise\NEWPAX at raise\hb at xt@\z@{%
+      \kern\NEWPAX at right
+      \ifNEWPAX at GoTo
+        %additional box for lualatex ...
+        \hbox{%
+          \@NEWPAX at linkgoto@xnn
+            {NEWPAX@\NEWPAX at file @\NEWPAX at key@DestLabel @\csname l__newpax_destsuffix_tl\endcsname}%
+            {\NEWPAX at width}%
+            {\NEWPAX at height}%
+            }%
+      \else
+        \hbox{%
+        \expandafter\@NEWPAX at link@setaction at nn\expandafter{\NEWPAX at link@type}{#1}%
+        \expandafter
+         \@NEWPAX at annotboxlink@nnn
+         \expandafter {\NEWPAX at link@type}{\NEWPAX at width}{\NEWPAX at height}{}}%
+      \fi
+      \hss
+    }%
+  \fi
+  \endgroup
+}
+
+\def\NEWPAX at htype@GoToR{file}
+\def\NEWPAX at htype@GoTo{link}
+\def\NEWPAX at htype@Named{link}
+\def\NEWPAX at htype@URI{url}
+
+\def\NEWPAX at link@URI{%
+  \NEWPAX at pdf@annot{%
+    /URI\NEWPAX at key@URI
+  }%
+}
+\ExplSyntaxOn
+\def\NEWPAX at link@Named{%
+  \NEWPAX at pdf@annot{%
+    /N \pdf_name_from_unicode_e:n{\NEWPAX at key@Name} %the value is from a pdf so we can assume it is correctly escaped??
+  }%
+}
+\ExplSyntaxOff
+\def\NEWPAX at link@GoToR{%
+  \NEWPAX at pdf@annot{%
+    /F\NEWPAX at key@File
+    /D%
+    \ifx\NEWPAX at key@DestName\@empty
+      [\NEWPAX at key@DestPage\space\NEWPAX at key@DestView]%
+    \else
+      \NEWPAX at key@DestName
+    \fi
+  }%
+}
+
+
+\AddLineBeginAux{%
+  \string\providecommand{\string\NEWPAX at DestReq}[2]{}%
+}
+\AddLineBeginAux{%
+  \string\providecommand{\string\NEWPAX at DestProv}[2]{}%
+}
+\AtBeginDocument{%
+  \let\NEWPAX at DestReq\@gobbletwo
+  \let\NEWPAX at DestProv\@gobbletwo
+}
+\def\NEWPAX at DestReq#1#2{%
+  \expandafter\gdef\csname NEWPAX at REQ@#1@#2\endcsname{}%
+}
+\def\NEWPAX at DestProv#1#2{%
+  \expandafter\gdef\csname NEWPAX at PROV@#1@#2\endcsname{}%
+}
+
+\def\NEWPAX at link@GoTo{%
+  \ifnum0<0\NEWPAX at key@DestLabel\relax
+    \expandafter\@firstofone
+  \else
+    \endgroup
+    \expandafter\@gobble
+  \fi
+  {%
+    \if at filesw
+      \protected at write\@auxout{}{%
+        \string\NEWPAX at DestReq{\NEWPAX at file}{\NEWPAX at key@DestLabel}%
+      }%
+    \fi
+    % Generate link, if destination exists
+    \@ifundefined{NEWPAX at PROV@\NEWPAX at file @\NEWPAX at key@DestLabel}{%
+      \endgroup
+    }{%
+      \NEWPAX at GoTotrue
+      \NEWPAX at pdf@annot{}%
+    }%
+  }%
+}
+
+\def\NEWPAX at cmd@dest#1#2#3#4{%
+  \NEWPAX at filter@page{#1}{%
+    \if at filesw
+      \protected at write\@auxout{}{%
+        \string\NEWPAX at DestProv{\NEWPAX at file}{#2}%
+      }%
+    \fi
+    \@ifundefined{NEWPAX at REQ@\NEWPAX at file @#2}{%
+    }{%
+      \begingroup
+        \let\NEWPAX at key@DestY\NEWPAX at page@ury
+        \let\NEWPAX at key@DestX\NEWPAX at page@llx
+        \kvsetkeys{NEWPAX}{#4}%
+        \let\NEWPAX at dest@llx\NEWPAX at key@DestX
+        \let\NEWPAX at dest@urx\NEWPAX at key@DestX
+        \let\NEWPAX at dest@lly\NEWPAX at key@DestY
+        \let\NEWPAX at dest@ury\NEWPAX at key@DestY
+        \ifx\NEWPAX at key@DestRect\@empty
+        \else
+          \def\NEWPAX at temp{dest}%
+          \expandafter\NEWPAX at getrect\expandafter\NEWPAX at temp
+          \NEWPAX at key@DestRect\@nil
+        \fi
+        \ifNEWPAX at Gin@clip
+          \ifx\NEWPAX at dest@llx<\NEWPAX at page@llx
+            \let\NEWPAX at dest@llx\NEWPAX at page@llx
+          \fi
+          \ifx\NEWPAX at dest@lly<\NEWPAX at page@lly
+            \let\NEWPAX at dest@lly\NEWPAX at page@lly
+          \fi
+          \ifx\NEWPAX at dest@urx>\NEWPAX at page@urx
+            \let\NEWPAX at dest@urx\NEWPAX at page@urx
+          \fi
+          \ifx\NEWPAX at dest@ury>\NEWPAX at page@ury
+            \let\NEWPAX at dest@ury\NEWPAX at page@ury
+          \fi
+          % at least prevent destinations outside the window
+          \ifx\NEWPAX at dest@llx>\NEWPAX at page@urx
+            \NEWPAX at dest@llx\NEWPAX at page@urx
+          \fi
+          \ifx\NEWPAX at dest@lly>\NEWPAX at page@ury
+            \NEWPAX at dest@lly\NEWPAX at page@ury
+          \fi
+          \ifx\NEWPAX at dest@urx<\NEWPAX at page@llx
+            \NEWPAX at dest@urx\NEWPAX at page@llx
+          \fi
+          \ifx\NEWPAX at dest@ury<\NEWPAX at page@lly
+            \NEWPAX at dest@ury\NEWPAX at page@lly
+          \fi
+        \fi
+        % I don't know, what is the best idea for rotated stuff,
+        % perhaps using the corner llx/ury
+        \ifcase 0\ifnum\NEWPAX at Gin@angle=90 1\fi
+                 \ifnum\NEWPAX at Gin@angle=180 2\fi
+                 \ifnum\NEWPAX at Gin@angle=270 3\fi\space
+          % angle = 0
+          \def\NEWPAX at raise{%
+            \NEWPAX at scale@y\dimexpr\NEWPAX at dest@lly-\NEWPAX at page@lly\relax
+          }%
+          \def\NEWPAX at right{%
+            \NEWPAX at scale@x\dimexpr\NEWPAX at dest@llx-\NEWPAX at page@llx\relax
+          }%
+        \or % angle = 90
+          \def\NEWPAX at raise{%
+            \NEWPAX at scale@x\dimexpr\NEWPAX at dest@llx-\NEWPAX at page@llx\relax
+          }%
+          \def\NEWPAX at right{%
+            \NEWPAX at scale@y\dimexpr\NEWPAX at page@ury-\NEWPAX at dest@ury\relax
+          }%
+        \or % angle = 180
+          \def\NEWPAX at raise{%
+            \NEWPAX at scale@y\dimexpr\NEWPAX at page@ury-\NEWPAX at dest@ury\relax
+          }%
+          \def\NEWPAX at right{%
+            \NEWPAX at scale@x\dimexpr\NEWPAX at page@urx-\NEWPAX at dest@urx\relax
+          }%
+        \or % angle = 270
+          \def\NEWPAX at raise{%
+            \NEWPAX at scale@x\dimexpr\NEWPAX at page@urx-\NEWPAX at dest@urx\relax
+          }%
+          \def\NEWPAX at right{%
+            \NEWPAX at scale@y\dimexpr\NEWPAX at dest@lly-\NEWPAX at page@lly\relax
+          }%
+        \fi
+        \edef\NEWPAX at name{NEWPAX@\NEWPAX at file @#2@\csname l__newpax_destsuffix_tl\endcsname}%
+        \let\NEWPAX at type\@empty
+        \newpax at str@if at eq@@nnT{#3}{FITR}{\def\NEWPAX at type{xyz}}%too lazy for now for better fitr
+        \newpax at str@if at eq@@nnT{#3}{XYZ}
+          {%
+            \def\NEWPAX at type{xyz}%
+            \ifx\NEWPAX at key@DestZoom\@empty
+            \else
+             \edef\NEWPAX at type{\fpeval{\NEWPAX at key@DestZoom *100}}%
+            \fi
+          }
+        \newpax at str@if at eq@@nnT{#3}{FIT}{\def\NEWPAX at type{fit}}
+        \newpax at str@if at eq@@nnT{#3}{FITB}{\def\NEWPAX at type{fitb}}
+        \newpax at str@if at eq@@nnT{#3}{FITH}{\def\NEWPAX at type{fith}}
+        \newpax at str@if at eq@@nnT{#3}{FITBH}{\def\NEWPAX at type{fitbh}}
+        \newpax at str@if at eq@@nnT{#3}{FITV}{\def\NEWPAX at type{fitv}}
+        \newpax at str@if at eq@@nnT{#3}{FITBV}{\def\NEWPAX at type{fitbv}}
+        \ifx\NEWPAX at type\@empty
+          \def\NEWPAX at type{xyz}%
+        \fi
+        \raise\NEWPAX at raise\hb at xt@\z@{%
+          \kern\NEWPAX at right
+          \hbox{\@NEWPAX at destination@xx {\NEWPAX at name}{\NEWPAX at type}}%
+          \hss
+        }%
+      \endgroup
+    }%
+    \NEWPAX at skip
+  }%
+}
+
+\SetupKeyvalOptions{family=NEWPAX,prefix=NEWPAX at key@}
+\DeclareStringOption{URI}
+\DeclareStringOption{Name}
+\DeclareStringOption{DestName}
+\DeclareStringOption{DestPage}
+\DeclareStringOption{DestView}
+\DeclareStringOption{File}
+\DeclareStringOption{C}
+\DeclareStringOption{Border}
+\DeclareStringOption{BS}
+\DeclareStringOption{H}
+\DeclareStringOption{DestLabel}
+\DeclareStringOption{DestRect}
+\DeclareStringOption{DestZoom}
+\define at key{NEWPAX}{DestX}{%
+  \NEWPAX at defaultbp\NEWPAX at key@DestX{#1}%
+}
+\define at key{NEWPAX}{DestY}{%
+  \NEWPAX at defaultbp\NEWPAX at key@DestY{#1}%
+}
+%% 
+%%
+%% End of file `newpax.sty'.


Property changes on: branches/branch2020.0/Master/texmf-dist/tex/latex/newpax/newpax.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property


More information about the tex-live-commits mailing list.