From 5c493fa092f3c78e6ae4478912d9bf62dbb6a85a Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 30 Jul 2021 11:23:08 +0300 Subject: [PATCH] cleanup... Signed-off-by: Alex A. Naanou --- photobook.cls | 160 ++++++++++++++++++++++++++------------------------ 1 file changed, 82 insertions(+), 78 deletions(-) diff --git a/photobook.cls b/photobook.cls index f24c62a..f0f3ca6 100644 --- a/photobook.cls +++ b/photobook.cls @@ -180,7 +180,88 @@ %---------------------------------------------------------------------- -% page / spread templates... +% Setup... + +\AtEndPreamble{ + +% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +% Metadata... + + \hypersetup{ + pdfinfo={ + Title={\@title}, + Subject={\@subject}, + Author={\@author}, + Keywords={\@keywords}, + }, + pdfpagelayout=\photobook@pdfpagelayout, + } + + +% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +% Geometry... + + \RecalculatePageLengths + + \geometry{ + % paper size (incl. bleeds)... + paperwidth=\bleedblockwidth, paperheight=\bleedblockheight, + bindingoffset=\bindingoffset, + % XXX these should be overridable... + % include header/footer/margin notes in printed area + twoside, includeall, nomarginpar, + ignorehead=false, ignorefoot=false, ignoremp=false, + % center printed area on page + vcentering, hcentering} + + +% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +% pdf boxes... + + % calculate pdf box dimensions in pt... + \edef\@pdfWidthPt{\strip@pt\dimexpr + 0.996264009963\bleedblockwidth \relax} + \edef\@pdfHeightPt{\strip@pt\dimexpr + 0.996264009963\bleedblockheight \relax} + \edef\@pdfBleedPt{\strip@pt\dimexpr + 0.996264009963\bleed \relax} + \edef\@pdfTopPt{\strip@pt\dimexpr + 0.996264009963\dimexpr + \bleedblockheight - \bleed \relax \relax} + \edef\@pdfRightPt{\strip@pt\dimexpr + 0.996264009963\dimexpr + \bleedblockwidth - \bleed \relax \relax} + + % set the boxes... + \ifxetex + % XXX not tested... + \AtBeginShipout{\AtBeginShipoutAddToBox{ + \special{pdf:put @thispage << + /MediaBox [0 0 \@pdfWidthPt\space \@pdfHeightPt] + /BleedBox [0 0 \@pdfWidthPt\space \@pdfHeightPt] + /ArtBox [\@pdfBleedPt\space \@pdfBleedPt\space \@pdfRightPt\space \@pdfTopPt] + /TrimBox [\@pdfBleedPt\space \@pdfBleedPt\space \@pdfRightPt\space \@pdfTopPt] + /CropBox [\@pdfBleedPt\space \@pdfBleedPt\space \@pdfRightPt\space \@pdfTopPt] + >>} }} + + \else + \edef\pdfboxes{ + /MediaBox [0 0 \@pdfWidthPt\space \@pdfHeightPt] + /BleedBox [0 0 \@pdfWidthPt\space \@pdfHeightPt] + /ArtBox [\@pdfBleedPt\space \@pdfBleedPt\space \@pdfRightPt\space \@pdfTopPt] + /TrimBox [\@pdfBleedPt\space \@pdfBleedPt\space \@pdfRightPt\space \@pdfTopPt] + /CropBox [\@pdfBleedPt\space \@pdfBleedPt\space \@pdfRightPt\space \@pdfTopPt] + } + \expandafter\pdfpageattr\expandafter{\pdfboxes} + \fi + +} % \AtEndPreamble{..} + + + + +%---------------------------------------------------------------------- +% Templates... % XXX @@ -188,82 +269,5 @@ -%---------------------------------------------------------------------- -\AtEndPreamble{ - -% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -% Metadata... - -\hypersetup{ - pdfinfo={ - Title={\@title}, - Subject={\@subject}, - Author={\@author}, - Keywords={\@keywords}, - }, - pdfpagelayout=\photobook@pdfpagelayout, -} - - -% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -% Geometry... - -\RecalculatePageLengths - -\geometry{ - % paper size (incl. bleeds)... - paperwidth=\bleedblockwidth, paperheight=\bleedblockheight, - bindingoffset=\bindingoffset, - % XXX these should be overridable... - % include header/footer/margin notes in printed area - twoside, includeall, nomarginpar, - ignorehead=false, ignorefoot=false, ignoremp=false, - % center printed area on page - vcentering, hcentering} - - -% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -% pdf boxes... - -% calculate pdf box dimensions in pt... -\edef\@pdfWidthPt{\strip@pt\dimexpr - 0.996264009963\bleedblockwidth \relax} -\edef\@pdfHeightPt{\strip@pt\dimexpr - 0.996264009963\bleedblockheight \relax} -\edef\@pdfBleedPt{\strip@pt\dimexpr - 0.996264009963\bleed \relax} -\edef\@pdfTopPt{\strip@pt\dimexpr - 0.996264009963\dimexpr - \bleedblockheight - \bleed \relax \relax} -\edef\@pdfRightPt{\strip@pt\dimexpr - 0.996264009963\dimexpr - \bleedblockwidth - \bleed \relax \relax} - -% set the boxes... -\ifxetex - % XXX not tested... - \AtBeginShipout{\AtBeginShipoutAddToBox{ - \special{pdf:put @thispage << - /MediaBox [0 0 \@pdfWidthPt\space \@pdfHeightPt] - /BleedBox [0 0 \@pdfWidthPt\space \@pdfHeightPt] - /ArtBox [\@pdfBleedPt\space \@pdfBleedPt\space \@pdfRightPt\space \@pdfTopPt] - /TrimBox [\@pdfBleedPt\space \@pdfBleedPt\space \@pdfRightPt\space \@pdfTopPt] - /CropBox [\@pdfBleedPt\space \@pdfBleedPt\space \@pdfRightPt\space \@pdfTopPt] - >>} }} - -\else - \edef\pdfboxes{ - /MediaBox [0 0 \@pdfWidthPt\space \@pdfHeightPt] - /BleedBox [0 0 \@pdfWidthPt\space \@pdfHeightPt] - /ArtBox [\@pdfBleedPt\space \@pdfBleedPt\space \@pdfRightPt\space \@pdfTopPt] - /TrimBox [\@pdfBleedPt\space \@pdfBleedPt\space \@pdfRightPt\space \@pdfTopPt] - /CropBox [\@pdfBleedPt\space \@pdfBleedPt\space \@pdfRightPt\space \@pdfTopPt] - } - \expandafter\pdfpageattr\expandafter{\pdfboxes} -\fi - - - -} % \AtEndPreamble{..} %---------------------------------------------------------------------- % vim:set ts=4 sw=4 :