[latex3-commits] [git/LaTeX3-latex3-pdfresources] testlinkstuff: pageattr, corrections (d452cb4)
Ulrike Fischer
fischer at troubleshooting-tex.de
Sat May 11 00:29:13 CEST 2019
Repository : https://github.com/latex3/pdfresources
On branch : testlinkstuff
Link : https://github.com/latex3/pdfresources/commit/d452cb4a6157d28e3f91a8c9922d87c3f730a650
>---------------------------------------------------------------
commit d452cb4a6157d28e3f91a8c9922d87c3f730a650
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Sat May 11 00:29:13 2019 +0200
pageattr, corrections
>---------------------------------------------------------------
d452cb4a6157d28e3f91a8c9922d87c3f730a650
hluatex-experimental.def | 57 ++++-----------
pageresources.tex | 52 ++++++++++++++
pdfresources.dtx | 177 +++++++++++++++++++++++++++++++++++++++++-----
test-pdfresources.tex | 15 ++--
4 files changed, 235 insertions(+), 66 deletions(-)
diff --git a/hluatex-experimental.def b/hluatex-experimental.def
index 1f2684d..c704df9 100644
--- a/hluatex-experimental.def
+++ b/hluatex-experimental.def
@@ -169,7 +169,7 @@
%\protected\def\pdfliteral {\pdfextension literal}
-\protected\edef\pdfpageattr {\pdfvariable pageattr}
+%\protected\edef\pdfpageattr {\pdfvariable pageattr}
\protected\edef\pdfpageresources {\pdfvariable pageresources}
%\protected\edef\pdfpagesattr {\pdfvariable pagesattr}
@@ -802,57 +802,30 @@
\Hy at DisableOption{pdftrapped}%
\Hy at DisableOption{pdfinfo}%
}
- \ExplSyntaxOff
+
\def\hyper at pagetransition{%
\ifx\@pdfpagetransition\relax
\else
- \expandafter\Hy at RemoveTransPageAttr
- \the\pdfpageattr^^J/Trans{}>>\END
- \ifx\@pdfpagetransition\@empty
- \else
- \edef\@processme{%
- \global\pdfpageattr{%
- \the\pdfpageattr
- ^^J/Trans << /S /\@pdfpagetransition\space >>%
- }%
- }%
- \@processme
- \fi
- \fi
-}
-\gdef\Hy at RemoveTransPageAttr#1^^J/Trans#2#3>>#4\END{%
- \ifx\\#2\\%
- \global\pdfpageattr{#1}%
- \else
- \Hy at RemoveTransPageAttr#1#4\END
+ \pdf_pageattr_gremove:n {Trans}
+ \tl_if_empty:NF \@pdfpagetransition
+ {
+ \pdf_pageattr_gput:nn {Trans}{<< /S /\@pdfpagetransition\space >>}
+ }
\fi
}
+
\def\hyper at pageduration{%
\ifx\@pdfpageduration\relax
\else
- \expandafter
- \Hy at RemoveDurPageAttr\the\pdfpageattr^^J/Dur{} \END
- \ifx\@pdfpageduration\@empty
- \else
- \edef\@processme{%
- \global\pdfpageattr{%
- \the\pdfpageattr
- ^^J/Dur \@pdfpageduration\space
- }%
- }%
- \@processme
- \fi
- \fi
-}
-\gdef\Hy at RemoveDurPageAttr#1^^J/Dur#2#3 #4\END{%
- \ifx\\#2\\%
- \global\pdfpageattr{#1}%
- \else
- \Hy at RemoveDurPageAttr#1#4\END
+ \pdf_pageattr_gremove:n {Dur}
+ \tl_if_empty:NF \@pdfpageduration
+ {
+ \pdf_pageattr_gput:nn {Dur}{\@pdfpageduration\space}
+ }
\fi
}
-%UF removed hyper at pagehidden (obsolete key)
-% removed \Hy at RemoveHidPageAttr#1^^J/Hid#2#3 #4\END{%
+\ExplSyntaxOff
+
\pdf at ifdraftmode{}{%
\g at addto@macro\Hy at EveryPageHook{%
diff --git a/pageresources.tex b/pageresources.tex
index 2e1fcb2..a18c66c 100644
--- a/pageresources.tex
+++ b/pageresources.tex
@@ -61,6 +61,8 @@ and then copies to the page attribute if these are empty (why?):
The values added here are simple arrays. The data structure is easy: One needs a property, a command to add and one to remove a key. The main open problem is when to move the content of the property to \verb`\pdfpagesattr` and how to force packages to use the property. Can one redefine \verb+\pdfpageattr+ so that \verb+\the\pdfpageattr+ doesn't gives bad errors?
+\subsection{Implementation}
+new values are stored in a prop, and at every change the register is updated. There is a test for changes so intermediate calls of the primitive can be detected and users are warned. The register is updated a last time at the end of the document.
\section{pdfpageattr}
\begin{itemize}
@@ -299,5 +301,55 @@ Some values in the catalog need special treatment. So we will have a central pro
\item OutputIntents: needs it own property, as more than one intent can be added. The \enquote{ID} of an intent is the value of OutputCondition, so there should be a way to test it.
\item
\end{itemize}
+
+\section{pdfinfo}
+\begin{itemize}
+\item The info dictionary (in the xref-dict) is filled by e.g. \verb+\pdfinfo+.
+\item Multiple appearances are concatenated.
+\item Standard entries are Title, Author, Subject, Keywords, Creator, Producer (all text strings), CreationDate (date), ModDate (date), Trapped (name: either /True, /False, or /Unknown).
+\item More entries are allowed, their value should be text strings.
+\item If the value is empty, the entries should be removed.
+\item A number of entries are added by the engine automatically but can be overwritten with own data.
+CreationDate and ModDate can be suppressed with \verb+\pdfinfoomitdate+. The fullbanner with \verb+\pdfsuppressptexinfo+.
+\begin{verbatim}
+12 0 obj
+<<
+/Producer (pdfTeX-1.40.20)
+/Creator (TeX)
+/CreationDate (D:20190510185641+02'00')
+/ModDate (D:20190510185641+02'00')
+/Trapped /False
+/PTEX.Fullbanner (This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/W32TeX) kpathsea version 6.3.1)
+>>
+endobj
+\end{verbatim}
+\end{itemize}
+
+\subsection{Use}
+\begin{description}
+ \item[ltnews.cls]
+ \item[beamerthemeTorinoTh]
+ \item[bgteubner.cls]
+ \item[exam-n.cls]
+ \item[factura.cls]
+ \item[hcart.cls]
+ \item[hrreport.cls]
+ \item[hcslides.cls]
+ \item[hustthesis.cls]
+ \item[hyperref]
+ \item[jmlrbook.cls]
+ \item[l3build/regression-test.tex]
+ \item[lion-msc.cls]
+ \item[pdfprivacy]
+ \item[pdfx]
+ \item[skb]
+ \item[skrapport.cls]
+ \item[legislation.cls]
+ \item[webquiz-doc.code.tex]
+ \item[zwpagelayout]
+
+\end{description}
+
+
\end{document}
diff --git a/pdfresources.dtx b/pdfresources.dtx
index 4e00da2..d479336 100644
--- a/pdfresources.dtx
+++ b/pdfresources.dtx
@@ -128,22 +128,22 @@
%<*package>
%some variants
\cs_generate_variant:Nn\driver_pdf_object_write:nn {nx}
-% helper command to output a key value of prop as needed in a dict.
-% name??????????? explicit spaces?
+% helper command to output a key + value of a prop as needed in a dict.
+% name? explicit spaces?
% not internal as perhaps needed also by users?
\cs_new:Npn \driver_pdf_dict_item:nn #1 #2 {/#1~#2~}
%</package>
% \end{macrocode}
-% \subsubsection{pdfpagesattr}
+%
+% \subsubsection{driver / pdfpagesattr}
% pdfpagesattr is a single token register which is output at the end of the compilation.
% It is normally used only a few times in a document, so it is okay to update the
-% register at every change.
-% We need to find a way to avoid that uses of the primitives interfere. For now, we issue
-% the push code at the end of document, so that it wins. But how to warn users?
+% register at every change. This also allows to test for unwanted changes.
+% throught uses of the primitives. We issue the push code also at the end of
+% the document, so that it wins.
%
% \begin{macrocode}
%<*package>
-
\prop_new:N \g_@@_pdf_pagesattr_prop
% setter:
\cs_new_protected:Npn \driver_pdf_pagesattr_gput:nn #1 #2
@@ -160,9 +160,9 @@
}
% remove:
-\cs_new_protected:Npn \driver_pdf_pagesattr_gremove:nn #1 #2
+\cs_new_protected:Npn \driver_pdf_pagesattr_gremove:n #1
{
- \prop_gremove:Nnn \g_@@_pdf_pagesattr_prop { #1 }{ #2}
+ \prop_gremove:Nn \g_@@_pdf_pagesattr_prop { #1 }
\@@_pdf_pagesattr_gpush:
}
@@ -192,6 +192,7 @@
{
\tl_set:Nx #1 {\tex_the:D \tex_pdfpagesattr:D}
}
+ \AtEndDocument{\@@_pdf_pagesattr_gpush:}
}
\sys_if_engine_luatex:T
@@ -208,11 +209,94 @@
{
\tl_set:Nx #1 {\tex_the:D \tex_pdfvariable:D pagesattr}
}
+
+ \AtEndDocument{\@@_pdf_pagesattr_gpush:}
}
-\AtEndDocument{\@@_pdf_pagesattr_gpush:}
+
%</package>
% \end{macrocode}
+% \subsubsection{driver / pdfpageattr}
+% pdfpageattr is a single token register which is output at the shipout for every page.
+% It is normally used only a few times in a document, so it is okay to update the
+% register at every change. This also allows to test for unwanted changes.
+% through uses of the primitives.
+% Open is the question if one need more shipout hooks to set e.g. Rotate on specific
+% pages.
+% See also https://tex.stackexchange.com/questions/479812/extension-of-rotating-package-to-set-pdf-rotation
+%
+% \begin{macrocode}
+%<*package>
+\prop_new:N \g_@@_pdf_pageattr_prop
+% setter:
+\cs_new_protected:Npn \driver_pdf_pageattr_gput:nn #1 #2
+ {
+ \prop_gput:Nnn \g_@@_pdf_pageattr_prop { #1 }{ #2}
+ \@@_pdf_pageattr_gpush:
+ }
+
+% getter from the prop:
+\cs_new_protected:Npn \driver_pdf_pageattr_get:nN #1 #2
+ {
+ \prop_get:NnN \g_@@_pdf_pageattr_prop { #1 }
+ \@@_pdf_pageattr_gpush:
+ }
+
+% remove:
+\cs_new_protected:Npn \driver_pdf_pageattr_gremove:n #1
+ {
+ \prop_gremove:Nn \g_@@_pdf_pageattr_prop { #1 }
+ \@@_pdf_pageattr_gpush:
+ }
+
+% push to the register
+\cs_new_protected:Npn \@@_pdf_pageattr_gpush:
+ {
+ \exp_args:NNx \tex_global:D \@@_pdf_pageattr:n
+ {
+ \prop_map_function:NN \g_@@_pdf_pageattr_prop \driver_pdf_dict_item:nn
+ }
+ }
+
+
+\sys_if_engine_pdftex:T
+{
+ %definition works also for luatex
+ \cs_new_protected:Npx \@@_pdf_pageattr:n #1
+ {
+ \exp_not:N \tex_global:D
+ \cs_if_exist:NTF \tex_pdfpageattr:D
+ { \tex_pdfpageattr:D }
+ { \tex_pdfvariable:D pageattr }
+ {#1}
+ }
+
+ \cs_new_protected:Npn \driver_pdf_pageattr_get:N #1
+ {
+ \tl_set:Nx #1 {\tex_the:D \tex_pdfpageattr:D}
+ }
+}
+
+\sys_if_engine_luatex:T
+{
+ \cs_new_protected:Npx \@@_pdf_pageattr:n #1
+ {
+ \exp_not:N \tex_global:D
+ \cs_if_exist:NTF \tex_pdfpageattr:D
+ { \tex_pdfpageattr:D }
+ { \tex_pdfvariable:D pageattr }
+ {#1}
+ }
+ \cs_new_protected:Npn \driver_pdf_pageattr_get:N #1
+ {
+ \tl_set:Nx #1 {\tex_the:D \tex_pdfvariable:D pageattr}
+ }
+}
+
+
+%</package>
+% \end{macrocode}
+%
% \subsubsection{other stuff}
% \begin{macrocode}
%<*package>
@@ -358,6 +442,54 @@
%</package>
% \end{macrocode}
+%
+% \subsection{pdfpageattr}
+%
+% A token register that is added to the page object when the page is shipped out.
+% The following command copy more or less the driver commands but add a few tests
+% and warning if other packages or users have used the primitive commands.
+% \begin{macrocode}
+%<*package>
+\msg_new:nnnn { pdf }{ pageattr-changed }
+ {
+ The~content~of~pageattr ~has~changed.~
+ Check~if~it~is~correct.
+ }
+ {
+ This~is~probably~due~to~some~package~or~command~using~the~
+ primitive~\token_to_str:N\pdfpageattr\c_space_tl or~an~equivalent~command~
+ instead~of~the~expl3~interface.
+ }
+\tl_new:N \g_@@_pageattr_tl
+
+\cs_new_protected:Npn \pdf_pageattr_gput:nn #1 #2
+ {
+ \driver_pdf_pageattr_get:N \l_tmpa_tl
+ \tl_if_eq:NNF \l_tmpa_tl \g_@@_pageattr_tl
+ {
+ \msg_warning:nn { pdf }{ pageattr-changed }
+ }
+ \driver_pdf_pageattr_gput:nn { #1 } { #2 }
+ \driver_pdf_pageattr_get:N \l_tmpa_tl
+ \tl_gset_eq:NN \g_@@_pageattr_tl \l_tmpa_tl
+ }
+
+\cs_new_protected:Npn \pdf_pageattr_gremove:n #1
+ {
+ \driver_pdf_pageattr_get:N \l_tmpa_tl
+ \tl_if_eq:NNF \l_tmpa_tl \g_@@_pageattr_tl
+ {
+ \msg_warning:nn { pdf }{ pageattr-changed }
+ }
+ \driver_pdf_pageattr_gremove:n { #1 }
+ \driver_pdf_pageattr_get:N \l_tmpa_tl
+ \tl_gset_eq:NN \g_@@_pageattr_tl \l_tmpa_tl
+ }
+
+
+%</package>
+% \end{macrocode}
+%
% \subsection{The info dictionary}
% The info dictionary is filled by e.g. \cs{pdfinfo}. Multiple appearances of
% \cs{pdfinfo} are concatenated, so one could end with multiple /Title or /Author entries.
@@ -366,39 +498,46 @@
% directory in one go. According to hyperref a few odd drivers (hvtex, dvipsone, dviwind)
% don't support arbitrary keys, but this should be handle elsewhere. Most entries are
% strings so there is a special command for this, as entries with empty content
-% should be ommited we add a test. The string command should perhaps escape the argument???
-% hyperref write the info dictionary at the shipout of the first page --
+% should be ommited we add a test. The string command should perhaps escape the argument,
+% but for now we are assuming that the argument is pdf safe.
+% hyperref writes to the info dictionary at the shipout of the first page --
% probably to catch the case that \cs{title} is issued after the begin of the document.
% We are outputting at begin document, so all info keys should be set before.
% \begin{macrocode}
%<*package>
%% should this be driver commands??
-\prop_new:N \g_@@_info_dict_prop
+\prop_new:N \g_@@_info_prop
\cs_new_protected:Npn \pdf_info_gput:nn #1 #2 %#1 key without /, #2 content
{
- \prop_gput:Nnn\g_@@_info_dict_prop { #1 } { #2 }
+ \prop_gput:Nnn\g_@@_info_prop { #1 } { #2 }
}
\cs_generate_variant:Nn \pdf_info_gput:nn {o}
+% should #2 be inside a some escaping command?
+% hyperref passes them through
+% \HyXeTeX at CheckUnicode
+% \HyPsd at XeTeXBigCharstrue
+% \HyPsd at PrerenderUnicode{#1}%
+% \pdfstringdef\@pdftitle{#1}%
\cs_new_protected:Npn \pdf_info_string_gput:nn #1 #2 %#1 key without /, #2 content
{
\tl_if_empty:nF { #2 }
{
- \prop_gput:Nnn\g_@@_info_dict_prop { #1 } { (#2) }
+ \prop_gput:Nnn\g_@@_info_prop { #1 } { (#2) }
}
}
\cs_generate_variant:Nn \pdf_info_string_gput:nn {no,oo,on}
-\cs_new_protected:Npn \@@_info_out: %internal, to ensure that it is used only once
+\cs_new_protected:Npn \@@_info_push: %internal, to ensure that it is used only once
{
- \prop_map_function:NN \g_@@_info_dict_prop \driver_pdf_info_gput:nn
- \prop_gclear:N \g_@@_info_dict_prop
+ \prop_map_function:NN \g_@@_info_prop \driver_pdf_info_gput:nn
+ \prop_gclear:N \g_@@_info_prop
}
-\AtBeginDocument{\@@_info_out:}
+\AtBeginDocument{\@@_info_push:}
%</package>
diff --git a/test-pdfresources.tex b/test-pdfresources.tex
index ba94a6f..24b1cb6 100644
--- a/test-pdfresources.tex
+++ b/test-pdfresources.tex
@@ -23,8 +23,8 @@
pdfversion=1.7,
% pdfstartpage=3,
% pdfstartview=
- pdfview=FitV,
- pdfpagescrop={0 0 300 300}
+ %pdfview=FitV,
+ % pdfpagescrop={0 0 300 300}
]{hyperref}
@@ -32,15 +32,20 @@
%\hypersetup{pdfview=FitV 50,pdfinfo={blub=bla,blb=zzz}}
-\usepackage{bookmark}
+\usepackage{bookmark,graphicx}
%%\tracingmacros=1
-\hypersetup{urlbordercolor=blue,linkbordercolor=green,pdfborder={1 1 1},pdfprintpagerange=0}
+\hypersetup{urlbordercolor=blue,linkbordercolor=green,pdfborder={1 1 1},pdfprintpagerange=0,pdfpagetransition=Dissolve}
%%%\makeatletter
%\hypupdateattribute
\makeatletter%\tracingmacros=1
-\textwidth=5cm
+%\textwidth=5cm
\begin{document}\parskip=1cm
%
+\includegraphics[page=1]{example-image-duck}
+spme text\newpage
+\includegraphics[page=2]{example-image-duck}
+some text
+\end{document}
\ExplSyntaxOn
\pdf_pagesattr_gput:nn {YYY}{(blbl)}
{\pdf_pagesattr_gput:nn {ZZZ}{(abc)}}
More information about the latex3-commits
mailing list