diff options
Diffstat (limited to 'Master/texmf-dist/tex/lualatex/novel/novel-pdfx.sty')
-rw-r--r-- | Master/texmf-dist/tex/lualatex/novel/novel-pdfx.sty | 523 |
1 files changed, 523 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/lualatex/novel/novel-pdfx.sty b/Master/texmf-dist/tex/lualatex/novel/novel-pdfx.sty new file mode 100644 index 00000000000..36f7bbb67ff --- /dev/null +++ b/Master/texmf-dist/tex/lualatex/novel/novel-pdfx.sty @@ -0,0 +1,523 @@ +%% +%% This is file `novel-pdfx.sty', part of `novel' document class. +%% +%% Copyright (c) 2017, Robert Allgeyer. +%% +%% This file may be distributed and/or modified under the conditions +%% of the LaTeX Project Public License, either version 1.3c of this +%% license or (at your option) any later version. The latest version +%% of this license is in: +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% ----------------------------------------------------------------------------- +%% +%% File `novel-pdfx.sty' uses code, directly copied or modified, +%% from file `pdfx.sty', part of LaTeX package `pdfx': Copyright (c) 2015, +%% CV Radhakrishnan, Han The Thanh, Ross Moore, Peter Selinger. +%% Licensed LPPL 1.2+. +%% +%% ----------------------------------------------------------------------------- +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesFile{novel-pdfx.sty} + [2017/03/01 v1.0.6 LaTeX file (PDF/X support for novel class)] +% This package supports, and is part of, class `novel'. +% No support for anything but LuaLaTeX. + + +%% +%% This file is loaded \AtEndPreamble. +%% + + +% +% Hyperref options for PDF/X with LuaTeX: +\def\pdfx@pdfX@opts@luatex{% + draft,pdftex,pdfpagemode=UseNone,bookmarks=false,hyperfootnotes=false,% + hyperindex=false,implicit=false,pdfversion=1.\the\pdfminorversion,% + pdfpagelabels=true,pageanchor=false,pdfstartview=} +% +\RequirePackage[\pdfx@pdfX@opts@luatex]{hyperref} +% +\hypersetup{pdfencoding=auto} +\expandafter\ifx\csname KV@Hyp@psdextra\endcsname\relax\else + \hypersetup{psdextra} +\fi +\Hy@bookmarksfalse +% +\newif \if@gottitle \@gottitlefalse % refers to PDF File Data +% Was \title{} called prior to this step? If so: +\ifthenelse{\equal{\@title}{} \OR \equal{\@title}{ }}{}{\@gottitletrue} +% +% Sanity check: If title is missing at this step, then compliance must be off: +\ifpdfx@isOFF\else + \if@gottitle\else + \ClassError{novel}{PDF/X requires \string\title\space first}% + {Unless \string\SetPDFX\space is off, must use \string\title\space ^^J% + before using \string\SetPDFX.^^J} + \fi +\fi +% +\if@gottitle\else + \ClassWarning{novel}{Your file has been compiled without standard^^J % + PDF internal metadata, such as the title. This is allowable, and in ^^J % + some cases desirable. But in most cases it is not what you intended. ^^J % + If you want title and other metadata to be in PDF internal metadata, ^^J % + then you must place them prior to the \string\SetPDFX.^^J} +\fi +% +\expandafter\ifx\csname pdfresetpageorigin\endcsname\relax\else + \pdfresetpageorigin=0 +\fi +\edef\pdfcreationdate{\pdfcreationdate}% +\let\pdfx@mdfivesum\pdf@mdfivesum +% + + + + +%% CALCULATE AND SPECIFY CROPBOX AND TRIMBOX +%% ----------------------------------------------------------------------------- +%% +% The MediaBox is automatically provided, so there is no need to write +% MediaBox in /pdfInfo (because it would be a duplicate). +% TrimBox is always necessary for PDF/X. +% Although CropBox is not necessary, it seems that it is often written +% by professional PDF software. For that reason, and for proper centering +% of TrimBox when MediaBox is larger, CropBox is created (= MediaBox). +% +\newcommand\my@MWnum{\strip@pt\New@MediaWidth} +\FPmul{\my@MWnum}{\my@MWnum}{0.99626401} +\FPround{\my@MWnum}{\my@MWnum}{3} +\FPclip{\my@MWnum}{\my@MWnum} +\newcommand\my@MHnum{\strip@pt\New@MediaHeight} +\FPmul{\my@MHnum}{\my@MHnum}{0.99626401} +\FPround{\my@MHnum}{\my@MHnum}{3} +\FPclip{\my@MHnum}{\my@MHnum} +\newcommand\my@TWnum{\strip@pt\New@TrimWidth} +\FPmul{\my@TWnum}{\my@TWnum}{0.99626401} +\FPround{\my@TWnum}{\my@TWnum}{3} +\newcommand\my@THnum{\strip@pt\New@TrimHeight} +\FPmul{\my@THnum}{\my@THnum}{0.99626401} +\FPround{\my@THnum}{\my@THnum}{3} +% +\FPsub{\my@TWorigin}{\my@MWnum}{\my@TWnum} +\FPmul{\my@TWorigin}{\my@TWorigin}{0.5} +\FPround{\my@TWorigin}{\my@TWorigin}{3} +\FPadd{\my@TWcorner}{\my@TWorigin}{\my@TWnum} +\FPround{\my@TWcorner}{\my@TWcorner}{3} +\FPsub{\my@THorigin}{\my@MHnum}{\my@THnum} +\FPmul{\my@THorigin}{\my@THorigin}{0.5} +\FPround{\my@THorigin}{\my@THorigin}{3} +\FPadd{\my@THcorner}{\my@THorigin}{\my@THnum} +\FPround{\my@THcorner}{\my@THcorner}{3} +% +\FPclip{\my@TWorigin}{\my@TWorigin} +\FPclip{\my@TWcorner}{\my@TWcorner} +\FPclip{\my@THorigin}{\my@THorigin} +\FPclip{\my@THcorner}{\my@THcorner} +% +\newcommand\novel@CropBox{% + \if@cropview% + /CropBox[\my@TWorigin\space\my@THorigin\space\my@TWcorner\space\my@THcorner]% + \else% + /CropBox[0\space0\space\my@MWnum\space\my@MHnum]% + \fi% +} +% +\newcommand\novel@TrimBox{% + /TrimBox[\my@TWorigin\space\my@THorigin\space\my@TWcorner\space\my@THcorner]% +} +% +\begingroup\edef\next{% +\endgroup\pdfpageattr{\novel@CropBox^^J\novel@TrimBox}}\next +% +%% End calculate and specify TrimBox. + + + +%% DISABLE HYPERLINKS AND BOOKMARKS +%% ----------------------------------------------------------------------------- +% +% Files for PDF/X cannot have hyperlinks. If your document has any, +% they will be functionally disabled. However, it is still necessary +% to ensure that you do not specify them in the wrong color space. +% Since `novel' class disallows any kind of color, `xcolor' is loaded with +% `monochrome' or `gray' option, prior to loading `hyperref'. +% +% Your text will be K black, rather than CMYK `rich black'. This is best. +% If you use a grayscale image anywhere, ask your print service whether it may +% be directly placed as grayscale (and they will convert to halftone) +% or whether you must convert it to halftone yourself, and place it that way. +% +% Note that LaTeX cannot detect any erroneous placement of a color image. +% +% The pagegrid package can only be used in draft mode, without PDF/X: +\gdef\@reallyOFF{off} +\@ifpackageloaded{pagegrid}{ + \if@useDraftMode\else + \ClassError{novel}{\string\pagegrid\space needs `draft' mode^^J}% + {\string\pagegrid\space may only be used with class option `draft'^^J}% + \fi + \ifpdfx@isOFF\else + \pdfx@isOFFtrue % cancels pdfx when using pagegrid (in draft mode) + \gdef\@reallyOFF{re-set to off by pagegrid package.} + \ClassWarning{novel}{You requested PDF/X compliance.^^J% + But you also used the \string\pagegrid\space package. Cannot have both.^^J% + So instead, your document was processed with \string\SetPDFX\space off.^^J% + Reason: The grid and text are in layers. No layers allowed.^^J}% + \fi +}{} + + + + +%% End disable hyperlinks and bookmarks. + + + +%% GENERAL PDF INTERNAL METADATA PREPARATION +%% ----------------------------------------------------------------------------- +% +% Create hashes that will be used for uuid data. Does not need to be fancy: +\edef\xmp@docid{\pdfx@mdfivesum{jobname.pdf}} +\edef\xmp@instid{\pdfx@mdfivesum{\pdfcreationdate}} +% +%% End general PDF in internal metadata preparation. + + + +%% PREPARATION OF XMP METADATA +%% ----------------------------------------------------------------------------- +%% Data prepared here, will later be inserted into the XMP packet template, +%% then the processed template will be incuded in the PDF. +%% XMP metadata is in utf-8 encoding. +% +% Make the XMP look pretty: +\def\pad@ii{\space\space} +\def\pad@iv{\pad@ii\pad@ii} +\def\pad@vi{\pad@iv\pad@ii} +\def\pad@viii{\pad@vi\pad@ii} +\def\pad@x{\pad@viii\pad@ii} +\def\pad@xii{\pad@x\pad@ii} +\def\pad@xiv{\pad@xii\pad@ii} +\def\pad@xvi{\pad@xiv\pad@ii} +\def\pad@xviii{\pad@xvi\pad@ii} +\def\pad@xx{\pad@xviii\pad@ii} +\def\pad@xxxii{\pad@xvi\pad@xvi} +\def\pad@lxiv{\pad@xxxii\pad@xxxii} +\def\pad@cxxviii{\pad@lxiv\pad@lxiv} +\def\pad@cclvi{\pad@cxxviii\pad@cxxviii} +\def\pad@dxii{\pad@cclvi\pad@cclvi} +% +% Frankly, I am not sure if all this rigamarole is necessary, but it works! +% Here, portions of XMP code are prepared. Later, they will be inserted +% into the XMP packet template. +\gdef\@titleString{ + \pad@vi<dc:title>^^J + \pad@viii<rdf:Alt>^^J + \pad@x<rdf:li xml:lang="x-default">\@title</rdf:li>^^J + \pad@viii</rdf:Alt>^^J + \pad@vi</dc:title>^^J +} +% +\ifthenelse{\equal{\@author}{}}{ + \gdef\@authorString{} +}{ + \gdef\@authorString{ + \pad@vi<dc:creator>^^J + \pad@viii<rdf:Bag>^^J + \pad@x<rdf:li>\@author</rdf:li>^^J + \pad@viii</rdf:Bag>^^J + \pad@vi</dc:creator>^^J + } +} +% +\def\@documentID{uuid:\xmp@docid} +\def\@instanceID{uuid:\xmp@instid} +% +\def\@pdfVersion{1.\the\pdfminorversion} +% +\ifpdfx@isOFF + \gdef\@verconfString{}% +\else + \gdef\@verconfString{ + \pad@vi<pdfx:GTS_PDFXVersion>\@PDFXversion</pdfx:GTS_PDFXVersion>^^J + \if@gotConformance + \pad@vi<pdfx:GTS_PDFXConformance>\@PDFXconformance</pdfx:GTS_PDFXConformance>^^J + \fi + } +\fi +% +\ifpdfx@isOFF + \gdef\@pdfidString{}% +\else + \gdef\@pdfidString{ + \pad@vi<pdfxid:GTS_PDFXVersion>\@PDFXversion</pdfxid:GTS_PDFXVersion>^^J + } +\fi +% +\ifthenelse{\equal{\@novelApplication}{} \OR \equal{\@novelApplication}{ }}{ + \gdef\@applicationString{}% +}{ + \gdef\@applicationString{\pad@vi<xmp:CreatorTool>\@novelApplication</xmp:CreatorTool>^^J}% +} +% +\ifthenelse{\equal{\@novelProducer}{} \OR \equal{\@novelProducer}{ }}{ + \gdef\@producerString{}% +}{ + \gdef\@producerString{\pad@vi<pdf:Producer>\@novelProducer</pdf:Producer>^^J}% +} +% +% Calculation of Dates and Times, which must be in a specific format. +% Each time you process to PDF, the current date/time is used, +% for all of the several metadata date/time strings. +\def\xmp@cDate{\pdfx@getYear} +{\catcode`\D=12 \catcode`\:=12 + \gdef\pdfx@getYear D:#1#2#3#4{\edef\pdfx@xYear{#1#2#3#4}\pdfx@getMonth} +} +\def\pdfx@getMonth#1#2{\edef\pdfx@xMonth{#1#2}\pdfx@getDay} +\def\pdfx@getDay#1#2{\edef\pdfx@xDay{#1#2}\pdfx@getHour} +\def\pdfx@getHour#1#2{\edef\pdfx@xHour{#1#2}\pdfx@getMin} +\def\pdfx@getMin#1#2{\edef\pdfx@xMin{#1#2}\pdfx@getSec} +\def\pdfx@getSec#1#2{\edef\pdfx@xSec{#1#2}\pdfx@getTZh} +\def\pdfx@getTZh{\futurelet\pdfx@next\pdfx@getTzh@branches} +% +{\catcode`\@=11 \catcode`\Z=12 \catcode`\+=12 \catcode`\-=12 % ends below +\gdef\pdfx@getTzh@branches{% + \ifx\pdfx@next Z\let\pdfx@getTzbranch\pdfx@getTznozone + \else\ifx\pdfx@next +\let\pdfx@getTzbranch\pdfx@getTzplus + \else\ifx\pdfx@next -\let\pdfx@getTzbranch\pdfx@getTzminus + \else\let\pdfx@getTzbranch\pdfx@getTzerror + \fi\fi\fi \pdfx@getTzbranch } +% +\catcode`\0=12 +\gdef\pdfx@getTznozone Z#1\pdfx@getTzend{% + \edef\pdfx@xTzh{+00}\edef\pdfx@xTzm{00}} +\gdef\pdfx@getTzplus +#1'#2'#3\pdfx@getTzend{% + \edef\pdfx@xTzh{+#1}\edef\pdfx@xTzm{#2}% + \ifx\relax#2\relax\def\pdfx@xTzm{00}\fi} +\gdef\pdfx@getTzminus -#1'#2'#3\pdfx@getTzend{% + \edef\pdfx@xTzh{-#1}\edef\pdfx@xTzm{#2}% + \ifx\relax#2\relax\def\pdfx@xTzm{00}\fi} +% +\expandafter\ifx\csname pdfcreationdate\endcsname\relax +\else + \expandafter\expandafter\expandafter\xmp@cDate\pdfcreationdate''\pdfx@getTzend + \xdef\pdfx@convDate{\pdfx@xYear\pdfx@xMonth\pdfx@xDay\pdfx@xHour + \pdfx@xMin\pdfx@xSec\pdfx@xTzh'\pdfx@xTzm'}% + \xdef\xmp@cDate{\pdfx@xYear-\pdfx@xMonth-\pdfx@xDay + T\pdfx@xHour:\pdfx@xMin:\pdfx@xSec\pdfx@xTzh:\pdfx@xTzm}% +\fi +}% End of \catcode`\@=11 etc. +\let\@modifyDate\xmp@cDate +\let\@createDate\xmp@cDate +\let\@metadataDate\xmp@cDate +% End dates and times. +% +%% End Prepare XMP metadata. + + + +%% WRITE THE XMP METADATA, UNLESS PDF/X IS OFF OR NO TITLE +%%------------------------------------------------------------------------------ +%% Inserts the prepared XMP metadata into XMP packet template, then writes +%% the result at the start of the PDF, right now, before the document. +% +\ifpdfx@isOFF\else + \if@gottitle + \begingroup + \makeatletter + \input{novel-xmppacket.sty} + \global\let\@xmpData\@xmpPacket % from the above file + \begingroup + \pdfcompresslevel=0 + \immediate\pdfobj stream attr {/Type /Metadata /Subtype /XML} {\@xmpData} + \pdfcatalog{/Metadata \the\pdflastobj\space 0 R} + \endgroup + \endgroup + % Creates external xml file, if requested: + \if@wantXMPasXML + \newwrite\file + \immediate\openout\file=\jobname-XMPasXML.xml + \immediate\write\file{<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>^^J} + \immediate\write\file{<!-- Ignore any message about not having style information. That is normal. -->^^J} + \immediate\write\file{<!-- Your viewer's font must be able to display any characters used in the XMP. -->^^J} + \immediate\write\file{<!-- For example, if your XMP has Cyrillic, then you need a Cyrillic-capable font. -->^^J} + \immediate\write\file{<!-- Any decorations (such as dashes in front of lines) are added by the viewer. Not in XMP. -->^^J} + \immediate\write\file{<!-- Note: xpacket begin="" contains the invisible 3-byte utf-8 BOM within its quotes. -->^^J} + \immediate\write\file{<!-- The above xml declaration, and these comments, are not part of the XMP packet. -->^^J} + \immediate\write\file{\@xmpData^^J} + \closeout\file + \fi + \fi +\fi +% +% +%% End write the XMP metadata. + + + +%% PREPARE PDF /INFO METADATA +%% ----------------------------------------------------------------------------- +%% PDF /Info is another form of metadata, older than XMP but still used. +%% It is NOT in utf-8 encoding. Depending on content, one of two encodings +%% will be automatically used: PDFDoc encoding if metadata uses only +%% characters within Latin-1, or utf-16 if metadata is not within Latin-1. +%% Either way, the input was utf-8 before processing. +%% In principle, PDF /Info is obsolete whenever PDF/X is used, because +%% XMP metadata is supposed to prevail through the printing workflow. +%% In practice, things don't always work that way. So, unless your PDF +%% has no metadata, essential items are re-encoded and copied to PDF /Info. +%% Other than encoding, XMP metadata and PDF /Info must be exactly the same. +%% All of those issues are handled automatically here. +%% The result is written at the end of the PDF, after the document. +% +% Macro for massaging encodings: +\def\@infotopdfstring#1#2{% + \ifx#2\@empty + \global\let#1\empty + \else + \begingroup + \hypersetup{pdfencoding=auto}% + \pdfstringdef#1{#2}% + \endgroup + \fi +} +% Now, massage the metadata: +\@infotopdfstring{\@infotitle}{\@title} +\@infotopdfstring{\@infoauthor}{\@author} +\@infotopdfstring{\@infoapplication}{\@novelApplication} +\@infotopdfstring{\@infoproducer}{\@novelProducer} +% +% Ensure Unicode glyph names: +\input{glyphtounicode.tex} % located in tex/generic/ +\input{novel-glyphtounicode.tex} % additional ligatures +\pdfgentounicode=1 +% End ensure Unicode glyph names. +% +%% End prepare PDF /Info. + + + +%% WRITE THE OUTPUT INTENT, UNLESS PDFX IS OFF. +%% ----------------------------------------------------------------------------- +% +\ifpdfx@isOFF\else + \begingroup + \edef\@pctchar{\expandafter\@gobble\string\%} % Escaped in TeX, not PDF. + \edef\@bchar{\expandafter\@gobble\string\\} % For use as escape, below. + \edef\0{\string\0} % Not sure why, but it works. + \edef\({\string\(} % PDF Catalog requires escaped parentheses. + \edef\){\string\)} % PDF Catalog requires escaped parentheses. + \catcode`\_ 12 % The *.icc file name might contain underscores. + % + \if@noembedicc\else + \IfFileExists{\@OIprofile}{% + \immediate\pdfobj stream attr{/N 4} file{\@OIprofile}% + \edef\OBJ@OI{\the\pdflastobj\space 0 R}% + }{% + \ClassError{novel}{Requested color profile *.icc not found}% + {Your Output Intent calls for a color profile *.icc file,^^J% + and you requested `embed-icc',^^J% + but the file could not be located.}% + } + \fi + \ifthenelse{\equal{\@OIcondition}{}}{ + \edef\@OIconditionString{}% + }{ + \edef\@OIconditionString{/OutputCondition (\@OIcondition)}% + } + \ifthenelse{\equal{\@OIidentifier}{}}{ + \edef\@OIidentifierString{}% + }{ + \edef\@OIidentifierString{/OutputConditionIdentifier (\@OIidentifier)}% + } + \ifthenelse{\equal{\@OIinfo}{}}{ + \edef\@OIinfoString{}% + }{ + \edef\@OIinfoString{/Info (\@OIinfo)}% + } + \ifthenelse{\equal{\@OIregistry}{}}{ + \edef\@OIregistryString{}% + }{ + \edef\@OIregistryString{/RegistryName (\@OIregistry)}% + } + \pdfcatalog{% + /OutputIntents [ <<% + /Type/OutputIntent% + /S/GTS_PDFX% + \@OIconditionString% + \@OIidentifierString% + \@OIinfoString% + \@OIregistryString% + \if@noembedicc\else/DestOutputProfile \OBJ@OI\fi% + >> ]% + }% + \endgroup +\fi +% +%% End write the output intent. + + + +%% DISABLE HYPERREF OPTIONS +%%------------------------------------------------------------------------------ +%% Prevents changes that will cause an incompatibility. +% +\Hy@DisableOption{pdfauthor}% +\Hy@DisableOption{pdftitle}% +\Hy@DisableOption{pdfsubject}% +\Hy@DisableOption{pdfcreator}% +\Hy@DisableOption{pdfcreationdate}% +\Hy@DisableOption{pdfmoddate}% +\Hy@DisableOption{pdfproducer}% +\Hy@DisableOption{pdfkeywords}% +% +%% End disable hyperref options. + + + +%% PREPARE PDF/Info +%% ----------------------------------------------------------------------------- +%% The \novel@PDFinfo command is called \AtBeginDocument. +% +\gdef\@novelPDFinfo{ % rather than \PDF@FinishDoc + \if@gottitle + \Hy@UseMaketitleInfos + \pdfinfo{ + \ifx\@infotitle\@empty\else /Title(\@infotitle)\fi + \ifx\@infoauthor\@empty\else /Author(\@infoauthor)\fi + \ifx\@infoapplication\@empty\else /Creator(\@infoapplication)\fi + \ifx\@pdfcreationdate\@empty + /CreationDate(D:\pdfx@convDate)% + \else + /CreationDate(\@pdfcreationdate)% + \fi + \ifx\@pdfmoddate\@empty + /ModDate(D:\pdfx@convDate)% + \else + /ModDate(\@pdfmoddate)% + \fi + \ifx\@infoproducer\@empty\else /Producer(\@infoproducer)\fi% + /Trapped/False% + \ifpdfx@isOFF\else + /GTS_PDFXVersion(\@PDFXversion)% + \if@gotConformance /GTS_PDFXConformance(\@PDFXconformance)\fi% + \fi + } + \fi +} +% +%% End prepare PDF/Info. + + + + +%% +%% End of file `novel-pdfx.sty'. + |