diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/pdfx/pdfx.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/pdfx/pdfx.sty | 256 |
1 files changed, 213 insertions, 43 deletions
diff --git a/Master/texmf-dist/tex/latex/pdfx/pdfx.sty b/Master/texmf-dist/tex/latex/pdfx/pdfx.sty index 00b7dcc0f5e..88936f4045f 100644 --- a/Master/texmf-dist/tex/latex/pdfx/pdfx.sty +++ b/Master/texmf-dist/tex/latex/pdfx/pdfx.sty @@ -6,9 +6,9 @@ %% %% pdfx.dtx (with options: `package') %% -%% Copyright (c) 2019, CV Radhakrishnan <cvr@river-valley.org>, +%% Copyright (c) 2019-2024, CV Radhakrishnan <cvr@river-valley.org>, %% Han The Thanh <thanh@river-valley.org>, -%% Ross Moore <ross.moore@mq.edu.au>, +%% Ross Moore <ozross@icloud.com> - primary contact, %% Peter Selinger <selinger@mathstat.dal.ca> %% %% This file may be distributed and/or modified under the conditions @@ -31,7 +31,7 @@ }{}% \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{pdfx} - [2019/02/27 v1.6.3 PDF/X and PDF/A support (CVR/HTH/RRM/PS)] + [2024/06/24 v1.6.5f PDF/X and PDF/A support (CVR/HTH/RRM/PS)] \newif\ifpdfx@noBOM \pdfx@noBOMfalse % use a BOM in the XMP packet \newif\ifpdfx@x \pdfx@xfalse % PDF/X mode @@ -50,13 +50,28 @@ \def\xmp@ReleaseDate{2005} % 2001 for PDF/X-1, 2005 for PDF/A-1, % 2010 for PDF/A-2, 2012 for PDF/A-3. +%% with Beamer pgf will have written Resource objects already +\newif\ifpdfx@luacheck@needed +\@ifpackageloaded{pgfcore}{\pdfx@luacheck@neededtrue}{} +%% thanks to Ryutaroh Matsumoto for reporting this issue + \newcount\pdfx@minorversion +\newcount\pdfx@majorversion +\expandafter\ifx\csname pdfmajorversion\endcsname\relax +%% RRM: 20240614 LuaLaTeX may not have this defined + \newcount\pdfmajorversion + \pdfmajorversion=1\relax +\fi \expandafter\ifx\csname pdfminorversion\endcsname\relax -\else - \global\pdfx@minorversion=\the\pdfminorversion +%% RRM: 20240614 this could be set in luatex85 package + \newcount\pdfminorversion + \pdfminorversion=3\relax \fi +%% options can change these from the defaults +\global\pdfx@majorversion=\the\pdfmajorversion +\global\pdfx@minorversion=\the\pdfminorversion -\def\pdfx@ErrorWarning#1#2#3#4{% +\def\pdfx@ErrorWarning #1#2#3#4{% \ifpdfx@noerr \PackageWarning{pdfx}{#1.^^J #2#3.^^J}% \else \PackageError{pdfx}{#1}{#2#4.^^J Use option 'noerr' to avoid this message.^^J}% @@ -237,6 +252,9 @@ \DeclareOption{pdf15}{\global\pdfx@minorversion=5 }% 2005 Acrobat 6 \DeclareOption{pdf16}{\global\pdfx@minorversion=6 }% 2006 Acrobat 7 (ISBN 0-321-30474-8) \DeclareOption{pdf17}{\global\pdfx@minorversion=7 }% 2008 ISO 32000-1:2008 +\DeclareOption{pdf20}{% 2020 ISO 32000-2:2020 + \global\pdfx@majorversion=2 \relax + \global\pdfx@minorversion=0 }% %% inhibits writing the XMP byte-order marker \DeclareOption{noBOM}{\pdfx@noBOMtrue} @@ -301,6 +319,13 @@ \ExecuteOptions{noBOM,a-1b} \ProcessOptions +\RequirePackage{ifluatex} +\ifpdfx@luacheck@needed + \ifluatex + \RequirePackage{luatex85} + \fi +\fi + \ifpdfx@ua\ifpdfx@x\else \expandafter\if\xmp@Conformance A\else \pdfx@ErrorWarning{PDF/UA requires 'Tagged PDF' for any structure.^^J @@ -313,19 +338,23 @@ \expandafter\ifx\csname pdflastobj\endcsname\relax \else - \ifnum\pdflastobj >\z@ % pdftex has already written objects + \ifnum\pdflastobj >\z@ % pdf/luatex has already written objects + % e.g. by pgfcore , called from Beamer or other class \ifnum\pdfx@minorversion=\pdfminorversion\else \PackageError{pdfx}% {^^J(pdfx) Cannot change the \string\pdfminorversion^^J% - (pdfx) PDF version remains at 1.\the\pdfminorversion.^^J% - (pdfx) Use \string\pdfminorversion=\the\pdfx@minorversion\space + (pdfx) PDF version remains at \the\pdfmajorversion.\the\pdfminorversion.^^J% + (pdfx) Use \string\pdfmajorversion=\the\pdfx@majorversion\space^^J% + and \string\pdfminorversion=\the\pdfx@minorversion\space before \string\documentclass}% {(pdfx) Another package or document-class has written objects into the PDF.^^J% - (pdfx) Hit return to continue with PDF version 1.\the\pdfminorversion.% - }% + (pdfx) Hit return to continue with PDF version % + \the\pdfmajorversion.\the\pdfminorversion.}% + \global\pdfx@majorversion=\the\pdfmajorversion \global\pdfx@minorversion=\the\pdfminorversion \fi \else + \global\pdfmajorversion\pdfx@majorversion \global\pdfminorversion\pdfx@minorversion \fi \fi @@ -333,6 +362,7 @@ \expandafter\ifx\csname thepdfminorversion\endcsname\relax \expandafter\ifx\csname pdfminorversion\endcsname\relax \else + \xdef\thepdfmajorversion{\the\pdfmajorversion} \xdef\thepdfminorversion{\the\pdfminorversion} \fi\fi @@ -341,16 +371,21 @@ \def\pdf@minorversion@xetex=#1{\gdef\thepdfminorversion{#1}}% \let\pdfminorversion\pdf@minorversion@xetex \else - \ifnum\pdfminorversion < 4\relax - \ifpdfx@x - % more testing needed with PDF/X - \else - \pdfminorversion=4\relax % assumed for PDF/A ; options may change this for PDF/X - \gdef\thepdfminorversion{4}% - \fi + \ifnum\pdfmajorversion > 1\relax + \pdfminorversion=3\relax + %% else some JPG graphics with DCT encoding will fail \else - \ifnum\pdfminorversion<\thepdfminorversion\relax - \global\pdfminorversion=\thepdfminorversion\relax + \ifnum\pdfminorversion < 4\relax + \ifpdfx@x + % more testing needed with PDF/X + \else + \pdfminorversion=4\relax % assumed for PDF/A ; options may change this for PDF/X + \gdef\thepdfminorversion{4}% + \fi + \else + \ifnum\pdfminorversion<\thepdfminorversion\relax + \global\pdfminorversion=\thepdfminorversion\relax + \fi \fi \fi \fi @@ -358,7 +393,8 @@ \pdfresetpageorigin=0 \fi -\expandafter\ifx\csname pdfomitcharset\endcsname\relax\else +\expandafter\ifx\csname pdfomitcharset\endcsname\relax +\else \ifpdfx@omitcharset \pdfomitcharset = 1 % %% do not create /Charset listings of font glyphs; @@ -427,7 +463,9 @@ }% \RequirePackage{pdftexcmds}% \let\pdfx@mdfivesum\pdf@mdfivesum - \let\pdfescapestring\pdf@escapestring + \long\def\pdf@escapestring@byte #1{% + \directlua {oberdiek.pdftexcmds.escapestring("\luaescapestring {#1}", "byte")}}% + %\let\pdf@escapestring\pdf@escapestring@byte \else \ifxetex \expandafter\ifx\csname mdfivesum\endcsname\relax @@ -477,6 +515,13 @@ \pdfgeninterwordspace=0 \relax \fi \begingroup + \expandafter\ifx\csname stockwidth\endcsname\relax\else + \ifdim\stockwidth=\z@ %% 20240528 + \else + %% 20231023 support for memoir's stockwidth/height + \let\paperwidth\stockwidth + \let\paperheight\stockheight + \fi \fi \dimen0=0.996264009963\paperwidth\relax \edef\pdfx@mwidth{\strip@pt\dimen0}% \advance\dimen0 -25\p@ @@ -524,7 +569,8 @@ \else \ifnum\thepdfminorversion >3 \relax \expandafter\ifx\csname pdfsuppresswarningdupmap\endcsname\relax - \expandafter\ifx\csname pdfmapline\endcsname\relax\else + \expandafter\ifx\csname pdfmapline\endcsname\relax + \else \pdfmapline{+dummy-space <dummy-space.pfb} \fi \else @@ -554,16 +600,31 @@ \@namedef{M@L8U}{}% %% adjust to LaTeX's 2018 change to the default encoding +\def\pdfx@utfencodingname{utf8}% +\def\pdfx@RawInputEncoding{% + \UseRawInputEncoding +} \expandafter\ifx\csname inputencodingname\endcsname\relax \else \def\pdfx@restoreencoding#1{% - \@tempcnta=128 + \@tempcnta=1\relax + \loop + \advance\@tempcnta\@ne + \ifnum\@tempcnta<8\relax + \repeat + \catcode11=13 \relax + \@tempcnta=14\relax + \loop + \advance\@tempcnta\@ne + \ifnum\@tempcnta<31 \relax + \repeat + \@tempcnta=128\relax \loop - \catcode\@tempcnta=13 \advance\@tempcnta\@ne \ifnum\@tempcnta<256 \repeat - \inputencoding{#1}% + \let\inputencodingname\relax %% kill previous + \inputencoding{#1}%}% \let\LastDeclaredEncoding\pdfx@LastDeclaredEncoding \let\DeclareFontEncoding@\pdfx@DeclareFontEncoding@ \let\DeclareUnicodeCharacter\pdfx@DeclareUnicodeCharacter @@ -572,7 +633,9 @@ \let\pdfx@inputencodingname\inputencodingname \global\let\pdfx@DeclareUnicodeCharacter\DeclareUnicodeCharacter \global\let\pdfx@DeclareFontEncoding@\DeclareFontEncoding@ - \UseRawInputEncoding +%% \expandafter\showthe\catcode\@tempcnta +%% if the encoding is utf8 then don't change it here – wrong! + \expandafter\pdfx@RawInputEncoding %\fi \fi \InputIfFileExists{\pdfx@encodingfile}{}{} \expandafter\ifx\csname pdfx@inputencodingname\endcsname\relax @@ -699,6 +762,9 @@ \ifx\relax#1\relax\else\gdef\xmp@lang@Identifier{#1}\fi \def\afterxmp@parse{\let\Identifier\pdfx@extraIdentifier}% \xmp@parse{\global\let\xmp@Identifier\@this}} +\newcommand{\pdfx@Nickname}[1][]{% + \ifx\relax#1\relax\else\gdef\xmp@lang@Nickname{#1}\fi + \xmp@parse{\global\let\xmp@Nickname\@this}} \newcommand{\pdfx@Thumbnails}{% \def\afterxmp@parse{\let\Thumbnails\pdfx@extraThumbnails}% \xmp@parse{\global\let\xmp@Thumbnails\@this}} @@ -899,6 +965,8 @@ \xmp@parse{\global\let\xmp@extraIdentifier\@this}% }% +%% Nickname only supports a single usage, for PDF/X + \newcommand{\pdfx@extraThumbnails}[1][]{% \ifx\relax#1\relax \expandafter\expandafter\expandafter\gdef @@ -1254,6 +1322,9 @@ %%---------------------------------------------------------------------- %% Alternative way to get the CreationDate using Lua for XeTeX \ifdefined\pdfcreationdate\else + \ifdefined\creationdate %% added to XeTeX in 2019 + \let\pdfcreationdate\creationdate + \else \begingroup %% ensure correct catcodes, not done by \dospecials \catcode`\:=12 \catcode`\.=12 \begin{filecontents*}{creationdate.lua} @@ -1289,7 +1360,7 @@ \def\noexpand\pdfcreationdate{\string D:20181028075445+10'00'}}% \x \fi -\fi +\fi \fi %%---------------------------------------------------------------------- \def\pdfx@findUUID#1{\edef\pdfx@tmpstring{\pdfx@mdfivesum{#1}} @@ -1460,7 +1531,6 @@ \fi\fi }% \fi\fi -\hypersetup{pdfencoding=auto}% unicode \expandafter\ifx\csname KV@Hyp@psdextra\endcsname\relax\else \hypersetup{psdextra} \fi @@ -2195,16 +2265,17 @@ %% encoding, and store the result in \toka As a special case, if \tokb %% is \@empty, set \toka to \@empty. -\def\pdfx@topdfstring#1#2{% - \ifx#2\@empty +\RequirePackage{stringenc}% prevent it loading later inside a group +\def\pdfx@topdfstring #1#2{% + \ifx #2\@empty \global\let#1\empty \else \begingroup \ifluatex\else\ifxetex\else \inputencoding{utf8}% \fi\fi - \hypersetup{pdfencoding=auto}% - \pdfstringdef#1{#2}% + \@ifl@t@r\fmtversion{2022/06/01}{}{\hypersetup{pdfencoding=auto}}% + \pdfstringdef #1{#2}% \endgroup \fi } @@ -2474,7 +2545,7 @@ \spacefactor\accent@spacefactor } %% same for named accents in math-mode -\def\pdfx@mathaccentV#1#2#3#4#5{% +\def\pdfx@mathaccentV #1#2#3#4#5{% #5{\mathsurround=\z@\relax \everymath{}% \mathchoice @@ -2485,10 +2556,67 @@ }% \AMS@mathaccentV{#1}{#2}{#3}{#4}{\phantom{#5}}% } + +%%% the original AMS coding: +%%\mathaccentV=macro: #1#2#3#4#5->\ifmmode +%% \gdef \macc@tmp {\macc@depth \@ne }% +%% \setbox \z@ \hbox {\let\mathaccentV \macc@test +%% \let \use@mathgroup \@gobbletwo +%% \let \select@group \@gobblethree \frozen@everymath {}$#5$}\macc@tmp +%% \ifnum \macc@depth =\@ne +%% \global \let \macc@nucleus \@empty +%% \mathaccent "\accentclass@ +%% \else \@xp \macc@nested +%% \fi #2#3#4{#5}\macc@nucleus +%% \else +%% \@xp \nonmatherr@ \csname #1\endcsname \fi . + +\def\pdfx@AMS@mathaccentV #1#2#3#4#5{% + \ifmmode + \gdef \macc@tmp {\macc@depth \@ne }% + \setbox \z@ \hbox {\let\mathaccentV \macc@test + \let \use@mathgroup \@gobbletwo + \let \select@group \@gobblethree \frozen@everymath {}$\phantom{#5}$}\macc@tmp + \ifnum \macc@depth =\@ne + \global \let \macc@nucleus \@empty + \mathaccent "\accentclass@ + \else \@xp \macc@nested + \fi #2#3#4{#5}\macc@nucleus + \else + \@xp \nonmatherr@ \csname #1\endcsname + \fi +} + +%% code supplied by Yuwsuke Kieda, 7 May 2019 : +%% https://gist.github.com/yuw/a31936370647d0044eeb4e47f3ae913f +%% +\@ifpackageloaded{amsmath}{% + \def\pdfx@macc@a #1#2{% + \begingroup + \let\macc@style#1\relax + \def\macc@palette ##1{##1\macc@style}% + \advance\macc@depth\m@ne + \ifnum\macc@depth=\z@ + \gdef\macc@nucleus{\phantom{#2}}%% <<< here + \setbox\z@\hbox{$#1#2\@empty{}\macc@skewchar$}% + \setbox\tw@\hbox{$#1#2\@empty\macc@skewchar$}% + \dimen@\tw@\wd\tw@ \advance\dimen@-\tw@\wd\z@ + \xdef\macc@kerna{\the\dimen@\relax}% + \setbox4\hbox{$#1#2\acc@check\@empty$}% + \global\setbox\@ne\hbox to\wd4{}% + \ht\@ne\ht4 \dp\@ne\dp4 + \xdef\macc@kernb{\the\wd4\relax}% + \mathaccent\macc@code{\box\@ne\kern\macc@kerna}% + \else + \mathaccent\macc@code{\let\macc@adjust\@empty #1#2\@empty}% + \macc@adjust + \fi + \endgroup + }}\relax \AtBeginDocument{% \@ifpackageloaded{amsmath}{% \let\AMS@mathaccentV\mathaccentV - \let\mathaccentV\pdfx@mathaccentV}% + }% }% %% How to support XeTeX here ? @@ -2740,10 +2868,25 @@ %% it should be loaded outside the grouping, else biblatex may barf %% \RequirePackage{ifthen} -\begingroup + +%% 2024-04-05: from July 2024 LaTeX will not allow packages to load +%% within a grouping, so reorganise a bit. +%% %% override the \ifpdf check of xmpincl package, inside the grouping - \pdftrue - \RequirePackage{xmpincl} +%% after saving its current value: +\let\pdfx@ifpdf\ifpdf +\pdftrue +%% now load the packages, then enter the grouping: +\RequirePackage{xmpincl} +%% +\begingroup +%%% 20240405 revert the value of \ifpdf ... +\pdfx@ifpdf +\else + %% 20240624 ... outside the grouping + \aftergroup\pdffalse +\fi + %% combine coding from xmpincl and hyperxml to support XeTeX \def\pdfx@xmpincl@xetex#1{% \IfFileExists{#1.xmp}{% @@ -2799,6 +2942,13 @@ %%---------------------------------------------------------------------- \begingroup +%% 20210706 we need a pointer to unexpandable \par + \expandafter\ifx\csname tex_par:D\endcsname \relax + \let\pdfx@par\par + \else +%% using LaTeX 2021-06 or later + \expandafter\let\expandafter\pdfx@par\csname tex_par:D\endcsname + \fi \ifpdfx@x \ifpdfx@vt \def\xmp@template{pdfvt}% @@ -2852,9 +3002,11 @@ %% beware 128 space characters -- for padding end of XMP packet \gdef\paddingline{ }% \typeout{Using XMP template file: \xmp@template.xmp}% + %% 20210706 ensure \par is unexpandable + \let\par\pdfx@par \includexmp{\xmp@template}% \endgroup - +%%% %% %% revert active characters to previous encoding %% @@ -2918,13 +3070,27 @@ %% %% controls the color model and conversions with xcolor package %% +\def\pdfx@selectcolormodel@doing #1{%% Warning + \PackageWarning{pdfx}{Setting all color commands to #1,^^J% + consistent with the Color Model for PDF/% + \ifpdfx@x X \else \ifpdfx@e E \else A \fi\fi}% + }%% 20240528 inhibit any changes +\def\pdfx@selectcolormodel@done #1{%% Warning + \PackageWarning{pdfx}{Color Model already set for PDF/% + \ifpdfx@x X\else \ifpdfx@e E\else A\fi\fi,^^Jcannot change to #1 }% + }%% 20240528 inhibit any changes +%% \ifpdfx@cmyk % % this will have been done already for PDF/X % \PassOptionsToPackage{cmyk,hyperref}{xcolor} - \def\pdfx@handlexcolor{\def\@@mod{cmyk}\selectcolormodel{cmyk}% - \convertcolorsUtrue\convertcolorsDtrue} + \def\pdfx@handlexcolor{\def\@@mod{cmyk}% + \pdfx@selectcolormodel@doing{cmyk}% + \selectcolormodel{cmyk}% + \convertcolorsUtrue\convertcolorsDtrue + \let\selectcolormodel\pdfx@selectcolormodel@done + } \ifpdfx@x \else %% \AtBeginDocument{% @@ -2947,8 +3113,12 @@ \fi \else \PassOptionsToPackage{rgb,hyperref}{xcolor} - \def\pdfx@handlexcolor{\def\@@mod{rgb}\selectcolormodel{rgb}% - \convertcolorsUtrue\convertcolorsDtrue} + \def\pdfx@handlexcolor{\def\@@mod{rgb}% + \pdfx@selectcolormodel@doing{rgb}% + \selectcolormodel{rgb}% + \convertcolorsUtrue\convertcolorsDtrue + \let\selectcolormodel\pdfx@selectcolormodel@done + } \fi \@ifpackageloaded{xcolor}{\pdfx@handlexcolor \ifpdfx@cmyk\else\color{black}\fi}{% |