From 1102f1b8bdada5b85eb1bf1831eaf3f8bee37506 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 1 Jul 2024 20:49:52 +0000 Subject: pdfx (1jul24) git-svn-id: svn://tug.org/texlive/trunk@71681 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/pdfx/pdfx.sty | 256 +++++++++++++++++++++++++----- 1 file changed, 213 insertions(+), 43 deletions(-) (limited to 'Master/texmf-dist/tex') 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 , +%% Copyright (c) 2019-2024, CV Radhakrishnan , %% Han The Thanh , -%% Ross Moore , +%% Ross Moore - primary contact, %% Peter Selinger %% %% 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 \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}{% -- cgit v1.2.3