From f54e9b3848627e535e145072d7461612bb183c0d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sun, 28 Aug 2022 03:01:47 +0000 Subject: CTAN sync 202208280301 --- macros/latex/contrib/pdfoverlay/pdfoverlay.dtx | 39 +++++++++++++------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'macros/latex/contrib/pdfoverlay/pdfoverlay.dtx') diff --git a/macros/latex/contrib/pdfoverlay/pdfoverlay.dtx b/macros/latex/contrib/pdfoverlay/pdfoverlay.dtx index 1ae9d9ded0..4990f49fa3 100644 --- a/macros/latex/contrib/pdfoverlay/pdfoverlay.dtx +++ b/macros/latex/contrib/pdfoverlay/pdfoverlay.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -% Copyright (c) 2018-2021 David Purton +% Copyright (c) 2018-2022 David Purton % % This work may be distributed and/or modified under the conditions of % the LaTeX Project Public License, either version 1.3c of this license @@ -23,10 +23,11 @@ % \changes{v1.2}{2020/10/29}{Update to use \pkg{l3hooks}} % \changes{v1.2a}{2021/02/25}{Ensure backend loaded before counting pages} % \changes{v1.2b}{2021/11/01}{Protect unexpandable macros} +% \changes{v1.3}{2022/08/27}{Allow PDF file name to be passed in as macro} % % \title{The \pkg{pdfoverlay} package} % \author{David Purton\thanks{Email: \url{dcpurton@marshwiggle.net}}} -% \date{2021/11/01 v1.2b} +% \date{2022/08/27 v1.3} % % \maketitle % @@ -165,7 +166,7 @@ % % \begin{macrocode} \NeedsTeXFormat{LaTeX2e}[2020-10-01] -\ProvidesExplPackage{pdfoverlay}{2021/11/01}{1.2b} +\ProvidesExplPackage{pdfoverlay}{2022/08/27}{1.3} {Overlay text on an existing PDF document (DCP)} % \end{macrocode} % @@ -177,14 +178,14 @@ % % \noindent Call \cs{@@_output_pdf_page:} on every page. % \begin{macrocode} -\AddToHook { shipout/background } { \@@_output_pdf_page: } +\hook_gput_code:nnn { shipout/background } { pdfoverlay } { \@@_output_pdf_page: } % \end{macrocode} % % \noindent Add an empty \cs{hbox:n} to the end of the document if an action % is pending. This is required to ensure that the last requested page from the % PDF file is output even if there isn't any other content on the page. % \begin{macrocode} -\AtEndDocument { +\hook_gput_code:nnn { enddocument } { pdfoverlay } { \bool_if:NT \g_@@_action_pending_bool { \hbox:n { } @@ -258,10 +259,10 @@ % % \subsection{Private Variables and Helper Functions} % -% \begin{macro}{\g_@@_pdf_file_name_str} +% \begin{macro}{\g_@@_pdf_file_name_tl} % Store the PDF file name. % \begin{macrocode} -\str_new:N \g_@@_pdf_file_name_str +\tl_new:N \g_@@_pdf_file_name_tl % \end{macrocode} % \end{macro} % @@ -333,7 +334,7 @@ { { \bool_if_p:N \g_@@_output_active_bool } { \bool_not_p:n - { \str_if_empty_p:N \g_@@_pdf_file_name_str } } + { \tl_if_empty_p:N \g_@@_pdf_file_name_tl } } { \int_compare_p:n { \c_zero_int <= \g_@@_page_int < \g_@@_page_count_int } } @@ -370,7 +371,7 @@ { \exp_not:N \includegraphics [ \clist_use:Nn \g_@@_graphics_options_clist { , } ] - { \g_@@_pdf_file_name_str } + { \g_@@_pdf_file_name_tl } } } } @@ -393,7 +394,7 @@ % The PDF page to be placed is available as the coffin % \cs{g_@@_pdf_page_coffin}. % \begin{macrocode} -\cs_new:Nn \@@_place_pdf_page: +\cs_new_protected:Nn \@@_place_pdf_page: { \put ( 0.5 \paperwidth, -0.5 \paperheight ) { @@ -405,7 +406,7 @@ % \end{macro} % % \begin{macro}{\@@_count_pdf_pages:} -% Count the number of pages in the current \cs{g_@@_pdf_file_name_str} and +% Count the number of pages in the current \cs{g_@@_pdf_file_name_tl} and % store the result in \cs{g_@@_pdf_page_count_int}. If no PDF has been set % with \cs{pdfoverlay_set_pdf} then \cs{g_@@_pdf_page_count_int} is set to % zero. @@ -413,7 +414,7 @@ \cs_new_protected:Nn \@@_count_pdf_pages: { \int_gzero:N \g_@@_page_count_int - \str_if_empty:NTF \g_@@_pdf_file_name_str + \tl_if_empty:NTF \g_@@_pdf_file_name_tl { \msg_error:nn { pdfoverlay } { file-not-set } } @@ -422,7 +423,7 @@ { \int_gset:Nn \g_@@_page_count_int { - \XeTeXpdfpagecount " \g_@@_pdf_file_name_str " + \XeTeXpdfpagecount " \g_@@_pdf_file_name_tl " } } { @@ -434,7 +435,7 @@ { \sys_if_engine_pdftex:TF { - \pdfximage { \g_@@_pdf_file_name_str } + \pdfximage { \g_@@_pdf_file_name_tl } \int_gset_eq:NN \g_@@_page_count_int \pdflastximagepages @@ -443,7 +444,7 @@ \sys_if_engine_luatex:TF { \saveimageresource - { \g_@@_pdf_file_name_str } + { \g_@@_pdf_file_name_tl } \int_gset_eq:NN \g_@@_page_count_int \lastsavedimageresourcepages @@ -470,7 +471,7 @@ % \begin{macrocode} \prg_new_conditional:Nnn \@@_if_page_exists:n { p, T, F, TF } { - \str_if_empty:NTF \g_@@_pdf_file_name_str + \tl_if_empty:NTF \g_@@_pdf_file_name_tl { \msg_error:nn { pdfoverlay } { file-not-set } \prg_return_false: @@ -485,7 +486,7 @@ } { \msg_error:nnxxx { pdfoverlay } { page-not-found } - { \str_use:N \g_@@_pdf_file_name_str } + { \g_@@_pdf_file_name_tl } { \int_eval:n { #1 } } { \int_use:N \g_@@_page_count_int } \prg_return_false: @@ -508,7 +509,7 @@ % \begin{macrocode} \file_if_exist:nTF { #1 } { - \str_gset:Nn \g_@@_pdf_file_name_str { #1 } + \tl_gset:Nn \g_@@_pdf_file_name_tl { #1 } % \end{macrocode} % Find the number of pages in the PDF file. % \begin{macrocode} @@ -521,7 +522,7 @@ \bool_gset_false:N \g_@@_action_pending_bool } { - \msg_error:nnn { pdfoverlay } { file-not-found } { #1 } + \msg_error:nnx { pdfoverlay } { file-not-found } { #1 } } } % \end{macrocode} -- cgit v1.2.3