| 1 |
%% |
| 2 |
%% This is file `pdfmanagement-firstaid.sty', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% pdfmanagement-firstaid.dtx (with options: `package') |
| 8 |
%% |
| 9 |
%% Copyright (C) 2019-2026 The LaTeX Project |
| 10 |
%% |
| 11 |
%% It may be distributed and/or modified under the conditions of |
| 12 |
%% the LaTeX Project Public License (LPPL), either version 1.3c of |
| 13 |
%% this license or (at your option) any later version. The latest |
| 14 |
%% version of this license is in the file: |
| 15 |
%% |
| 16 |
%% https://www.latex-project.org/lppl.txt |
| 17 |
%% |
| 18 |
%% This file is part of the "LaTeX PDF management bundle" (The Work in LPPL) |
| 19 |
%% and all files in that bundle must be distributed together. |
| 20 |
%% |
| 21 |
%% File: pdfmanagement-firstaid.dtx |
| 22 |
\ProvidesExplPackage{pdfmanagement-firstaid}{2026-05-26}{0.97c} |
| 23 |
{LaTeX PDF management bundle / firstaid-patches} |
| 24 |
|
| 25 |
\clist_map_inline:nn |
| 26 |
{pgf,xmp,xcolor,color,output,colorspace,luacolor} |
| 27 |
{ |
| 28 |
\bool_new:c { g__pdfmanagement_firstaid_#1_bool } |
| 29 |
\bool_gset_true:c { g__pdfmanagement_firstaid_#1_bool } |
| 30 |
} |
| 31 |
\clist_map_inline:Nn \g__pdfmanagement_firstaidoff_clist |
| 32 |
{ |
| 33 |
\bool_if_exist:cT { g__pdfmanagement_firstaid_#1_bool } |
| 34 |
{ |
| 35 |
\bool_gset_false:c { g__pdfmanagement_firstaid_#1_bool } |
| 36 |
} |
| 37 |
} |
| 38 |
\msg_new:nnn { pdfmanagement } { firstaid } |
| 39 |
{ loading~pdfmanagement~firstaid~code~for~#1 } |
| 40 |
\msg_new:nnn { pdfmanagement } { firstaid-changed } |
| 41 |
{ package~#1~has~changed.~Check~if~patch~is~still~valid! } |
| 42 |
\msg_new:nnn { pdfmanagement } { firstaid-disabled } |
| 43 |
{ The~loading~of~package~#1~is~disabled.\\ |
| 44 |
It~is~not~compatible~with~the~PDF~management. } |
| 45 |
\msg_new:nnn { pdfmanagement } { firstaid-too-old } |
| 46 |
{ Package~#1~is~too~old~and~not~compatible.\\ |
| 47 |
Get~at~least~version~#2.} |
| 48 |
|
| 49 |
\bool_if:NT \g__pdfmanagement_firstaid_color_bool |
| 50 |
{ |
| 51 |
\declare@file@substitution{color.sty}{color-ltx.sty} |
| 52 |
} |
| 53 |
\bool_if:NT \g__pdfmanagement_firstaid_xcolor_bool |
| 54 |
{ |
| 55 |
\AddToHook |
| 56 |
{ |
| 57 |
package/xcolor/after |
| 58 |
} |
| 59 |
{\RequirePackage{xcolor-patches-tmp-ltx}} |
| 60 |
\DeclareHookRule{package/xcolor/after}{pdfmanagement-firstaid}{before}{xcolor} |
| 61 |
} |
| 62 |
\bool_lazy_all:nT |
| 63 |
{ |
| 64 |
{\sys_if_engine_luatex_p:} |
| 65 |
{\g__pdfmanagement_firstaid_luacolor_bool} |
| 66 |
{\sys_if_output_pdf_p:} |
| 67 |
} |
| 68 |
{ |
| 69 |
\AddToHook{package/luacolor/after} |
| 70 |
{ |
| 71 |
\cs_set_protected:Npn \__color_backend_select:nn #1#2 |
| 72 |
{ |
| 73 |
\tl_set:Nn \l__color_backend_fill_tl {#1} |
| 74 |
\tl_set:Nn \l__color_backend_stroke_tl {#2} |
| 75 |
\LuaCol@setattribute\LuaCol@Attribute |
| 76 |
{ |
| 77 |
\directlua |
| 78 |
{ |
| 79 |
oberdiek.luacolor.get("\luaescapestring{#1~#2}") |
| 80 |
} |
| 81 |
} |
| 82 |
} |
| 83 |
\cs_set_protected:Npn \__color_backend_fill:n #1 |
| 84 |
{ |
| 85 |
\tl_set:Nn \l__color_backend_fill_tl {#1} |
| 86 |
\LuaCol@setattribute\LuaCol@Attribute |
| 87 |
{ |
| 88 |
\directlua |
| 89 |
{ |
| 90 |
oberdiek.luacolor.get("\luaescapestring{#1}") |
| 91 |
} |
| 92 |
} |
| 93 |
} |
| 94 |
\cs_set_protected:Npn \__color_backend_stroke:n #1 |
| 95 |
{ |
| 96 |
\tl_set:Nn \l__color_backend_stroke_tl {#1} |
| 97 |
\LuaCol@setattribute\LuaCol@Attribute |
| 98 |
{ |
| 99 |
\directlua |
| 100 |
{ |
| 101 |
oberdiek.luacolor.get("\luaescapestring{#1}") |
| 102 |
} |
| 103 |
} |
| 104 |
} |
| 105 |
\cs_set_protected:Npn \__color_backend_reset: {} |
| 106 |
\cs_set_eq:NN \__color_backend_fill_reset: \__color_backend_reset: |
| 107 |
\cs_set_eq:NN \__color_backend_stroke_reset: \__color_backend_reset: |
| 108 |
} |
| 109 |
} |
| 110 |
|
| 111 |
\bool_if:NT \g__pdfmanagement_firstaid_pgf_bool |
| 112 |
{ |
| 113 |
\msg_info:nnn{pdfmanagement }{firstaid}{pgf} |
| 114 |
\AddToHook |
| 115 |
{ |
| 116 |
file/pgfrcs.sty/after |
| 117 |
} |
| 118 |
{ |
| 119 |
\cs_set_eq:NN |
| 120 |
\__pdfmanagement_pgfori_pgfutil@setuppdfresources |
| 121 |
\pgfutil@setuppdfresources |
| 122 |
\def\pgfutil@setuppdfresources |
| 123 |
{ |
| 124 |
\__pdfmanagement_pgf_sys_setuppdfresources_plain: |
| 125 |
} |
| 126 |
} |
| 127 |
} |
| 128 |
\cs_new_protected:Npn \__pdfmanagement_pgf_sys_setuppdfresources_plain: |
| 129 |
{ |
| 130 |
%objects are already created ... |
| 131 |
\def\pgf@sys@pdf@possible@resources |
| 132 |
{ |
| 133 |
/ColorSpace~\pdf_object_ref:n {__pdf/Page/Resources/ColorSpace} |
| 134 |
/Pattern ~\pdf_object_ref:n {__pdf/Page/Resources/Pattern} |
| 135 |
/ExtGState ~\pdf_object_ref:n {__pdf/Page/Resources/ExtGState} |
| 136 |
} |
| 137 |
\let\pgf@sys@pdf@check@resources=\relax% |
| 138 |
%not sure if needed, but perhaps the lists are used somewhere else ... |
| 139 |
\let\pgf@sys@pgf@resource@list@extgs=\pgfutil@empty% |
| 140 |
\let\pgf@sys@pgf@resource@list@patterns=\pgfutil@empty% |
| 141 |
\let\pgf@sys@pgf@resource@list@colorspaces=\pgfutil@empty% |
| 142 |
% the commands to add page resources |
| 143 |
\def\pgf@sys@addpdfresource@extgs@plain##1 |
| 144 |
{ |
| 145 |
%\exp_after:wN %for transparent which passes a command |
| 146 |
\__pdfmanagement_patch_pgfextgs:w ##1\q_stop |
| 147 |
} |
| 148 |
\def\pgf@sys@addpdfresource@patterns@plain##1 |
| 149 |
{ |
| 150 |
\__pdfmanagement_patch_pgfpatterns:w ##1\q_stop |
| 151 |
} |
| 152 |
\def\pgf@sys@addpdfresource@colorspaces@plain##1 |
| 153 |
{ |
| 154 |
\__pdfmanagement_patch_pgfcolorspaces:w ##1\q_stop |
| 155 |
} |
| 156 |
} |
| 157 |
|
| 158 |
\cs_new:Npn \__pdfmanagement_split_dict_entry_aux:NNw #1 #2 /#3~#4\q_stop |
| 159 |
{ |
| 160 |
\tl_set:Nn #1 {#3} |
| 161 |
\tl_set:Nn #2 {#4} |
| 162 |
} |
| 163 |
|
| 164 |
\cs_generate_variant:Nn \tl_trim_spaces:n{V} |
| 165 |
\cs_generate_variant:Nn \pdfmanagement_add:nnn {nee} |
| 166 |
\cs_new:Npn \__pdfmanagement_patch_pgfextgs:w #1/#2<<#3>>#4\q_stop |
| 167 |
{ |
| 168 |
\tl_set:Ne\l_tmpa_tl{#2} |
| 169 |
\pdfmanagement_add:nee |
| 170 |
{Page/Resources/ExtGState}{\tl_trim_spaces:V\l_tmpa_tl}{<<#3 #4>>} |
| 171 |
} |
| 172 |
\cs_new:Npn \__pdfmanagement_patch_pgfpatterns:w #1/#2\space#3\q_stop |
| 173 |
{ |
| 174 |
\pdfmanagement_add:nee |
| 175 |
{Page/Resources/Pattern}{\tl_trim_spaces:n{#2}}{#3} |
| 176 |
} |
| 177 |
\cs_new:Npn \__pdfmanagement_patch_pgfcolorspaces:w #1/#2[#3]#4\q_stop |
| 178 |
{ |
| 179 |
\pdfmanagement_add:nee |
| 180 |
{Page/Resources/ColorSpace}{\tl_trim_spaces:n{#2}}{[#3]} |
| 181 |
} |
| 182 |
|
| 183 |
\bool_if:NT \g__pdfmanagement_firstaid_xmp_bool |
| 184 |
{ |
| 185 |
\disable@package@load{hyperxmp}{\msg_warning:nnn{pdfmanagement}{firstaid-disabled}{hyperxmp}} |
| 186 |
\disable@package@load{pdfx} {\msg_warning:nnn{pdfmanagement}{firstaid-disabled}{pdfx}} |
| 187 |
\AddToHook{package/doclicense/after} |
| 188 |
{ |
| 189 |
\AtBeginDocument |
| 190 |
{ |
| 191 |
\hypersetup |
| 192 |
{ |
| 193 |
pdfcopyright = {\doclicenseLongTextForHyperref}, |
| 194 |
pdflicenseurl = {\doclicenseURL}, |
| 195 |
} |
| 196 |
} |
| 197 |
} |
| 198 |
} |
| 199 |
\bool_if:NT \g__pdfmanagement_firstaid_colorspace_bool |
| 200 |
{ |
| 201 |
\AddToHook |
| 202 |
{ |
| 203 |
package/colorspace/after |
| 204 |
} |
| 205 |
{\RequirePackage{colorspace-patches-tmp-ltx}} |
| 206 |
} |
| 207 |
%% |
| 208 |
%% |
| 209 |
%% End of file `pdfmanagement-firstaid.sty'. |