diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/pdfoverlay')
-rw-r--r-- | Master/texmf-dist/tex/latex/pdfoverlay/pdfoverlay.sty | 103 |
1 files changed, 80 insertions, 23 deletions
diff --git a/Master/texmf-dist/tex/latex/pdfoverlay/pdfoverlay.sty b/Master/texmf-dist/tex/latex/pdfoverlay/pdfoverlay.sty index 45ac7a4cd1e..e5960ecbcd0 100644 --- a/Master/texmf-dist/tex/latex/pdfoverlay/pdfoverlay.sty +++ b/Master/texmf-dist/tex/latex/pdfoverlay/pdfoverlay.sty @@ -8,7 +8,7 @@ %% %% This is a generated file. %% -%% Copyright (c) 2018-2019 David Purton <dcpurton@marshwiggle.net> +%% Copyright (c) 2018-2020 David Purton <dcpurton@marshwiggle.net> %% %% This work may be distributed and/or modified under the conditions of %% the LaTeX Project2 Public License, either version 1.3c of this license @@ -24,15 +24,15 @@ %% This work consists of the files pdfoverlay.ins, pdfoverlay.dtx, README.md, %% and the derived files pdfoverlay.sty and pdfoverlay.pdf %% -\RequirePackage{xparse} -\ProvidesExplPackage{pdfoverlay}{2019/11/03}{1.1} +\NeedsTeXFormat{LaTeX2e}[2020-10-01] +\ProvidesExplPackage{pdfoverlay}{2020/10/18}{1.2} {Overlay text on an existing PDF document (DCP)} -\RequirePackage{everypage,pdfpages} -\AddEverypageHook { \__pdfoverlay_output_pdf_page: } +\RequirePackage{graphicx} +\AddToHook { shipout/background } { \__pdfoverlay_output_pdf_page: } \AtEndDocument { \bool_if:NT \g__pdfoverlay_action_pending_bool { - \null + \hbox:n { } } } \msg_new:nnnn { pdfoverlay } { file-not-found } @@ -52,6 +52,14 @@ { You~have~requested~to~include~to~page~#1, \\ but~the~current~page~is~already~at~page~#2. \\ Specify~a~page~between~#2~and~#3. } +\msg_new:nnnn { pdfoverlay } { dvi-mode } + { DVI~mode~not~supported. } + { DVI~mode~of~#1~is~not~supported. \\ + You~must~use~PDF~mode. } +\msg_new:nnnn { pdfoverlay } { unsupported-engine } + { #1~not~supported. } + { The~#1~engine~is~not~supported. \\ + Use~one~of~pdftex,~luatex,~or~xetex. } \str_new:N \g__pdfoverlay_pdf_file_name_str \int_new:N \g__pdfoverlay_page_count_int \int_new:N \g__pdfoverlay_page_int @@ -65,6 +73,7 @@ height = \paperheight , page = \int_use:N \g__pdfoverlay_page_int } +\coffin_new:N \g__pdfoverlay_pdf_page_coffin \cs_new:Nn \__pdfoverlay_output_pdf_page: { \bool_lazy_all:nT @@ -77,25 +86,75 @@ < \g__pdfoverlay_page_count_int } } } { - \AddToShipoutPictureBG* - { - \__pdfoverlay_format_pdf_page: - } \int_gincr:N \g__pdfoverlay_page_int + \__pdfoverlay_format_pdf_page: + \__pdfoverlay_place_pdf_page: \bool_gset_false:N \g__pdfoverlay_action_pending_bool } } \cs_new:Nn \__pdfoverlay_format_pdf_page: { - \AtPageCenter + \hcoffin_gset:Nn \g__pdfoverlay_pdf_page_coffin + { + \use:x + { + \exp_not:N \includegraphics + [ \clist_use:Nn \g__pdfoverlay_graphics_options_clist { , } ] + { \g__pdfoverlay_pdf_file_name_str } + } + } + } +\cs_new:Nn \__pdfoverlay_place_pdf_page: + { + \put ( 0.5 \paperwidth, -0.5 \paperheight ) + { + \coffin_typeset:Nnnnn \g__pdfoverlay_pdf_page_coffin + { hc } { vc } { 0pt } { 0pt } + } + } +\cs_new:Nn \__pdfoverlay_count_pdf_pages: + { + \int_gzero:N \g__pdfoverlay_page_count_int + \str_if_empty:NTF \g__pdfoverlay_pdf_file_name_str + { + \msg_error:nn { pdfoverlay } { file-not-set } + } { - \makebox (0, 0) + \sys_if_engine_xetex:TF { - \use:x + \int_gset:Nn \g__pdfoverlay_page_count_int + { + \XeTeXpdfpagecount " \g__pdfoverlay_pdf_file_name_str " + } + } + { + \sys_if_output_pdf:TF + { + \sys_if_engine_pdftex:TF + { + \pdfximage { \g__pdfoverlay_pdf_file_name_str } + \int_gset_eq:NN + \g__pdfoverlay_page_count_int + \pdflastximagepages + } + { + \sys_if_engine_luatex:TF + { + \saveimageresource + { \g__pdfoverlay_pdf_file_name_str } + \int_gset_eq:NN + \g__pdfoverlay_page_count_int + \lastsavedimageresourcepages + } + { + \msg_error:nnx { pdfoverlay } { unsupported-engine } + { \c_sys_engine_str } + } + } + } { - \exp_not:N \includegraphics - [ \clist_use:Nn \g__pdfoverlay_graphics_options_clist { , } ] - { \g__pdfoverlay_pdf_file_name_str } + \msg_error:nnx { pdfoverlay } { dvi-mode } + { \c_sys_engine_str } } } } @@ -129,10 +188,8 @@ \file_if_exist:nTF { #1 } { \str_gset:Nn \g__pdfoverlay_pdf_file_name_str { #1 } - \edef \AM@currentdocname { #1 } - \AM@getpagecount - \int_gset_eq:NN \g__pdfoverlay_page_count_int \AM@pagecount - \int_gset_eq:NN \g__pdfoverlay_page_int \c_zero_int + \__pdfoverlay_count_pdf_pages: + \int_gzero:N \g__pdfoverlay_page_int \bool_gset_true:N \g__pdfoverlay_output_active_bool \bool_gset_false:N \g__pdfoverlay_action_pending_bool } @@ -165,12 +222,12 @@ { \int_compare_p:n { #1 != \g__pdfoverlay_page_int + 1 } } } { - \null + \hbox:n { } \clearpage } \int_while_do:nNnn { \g__pdfoverlay_page_int } < { #1 - 1 } { - \null + \hbox:n { } \clearpage } \bool_gset_true:N \g__pdfoverlay_action_pending_bool @@ -193,7 +250,7 @@ { \bool_if:nT { \g__pdfoverlay_action_pending_bool } { - \null + \hbox:n { } \clearpage } \int_gset:Nn \g__pdfoverlay_page_int { #1 - 1 } |