summaryrefslogtreecommitdiff
path: root/macros/generic
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-06-15 03:00:50 +0000
committerNorbert Preining <norbert@preining.info>2022-06-15 03:00:50 +0000
commitda68bce1d25d68087ca3b70134a61ae1c3a96b67 (patch)
tree4d176d7c6b7c9bdbe49b9d24d72b61493ff25dc1 /macros/generic
parent0123ca8e30234615dca0d8853dffec2fb93fe9a8 (diff)
CTAN sync 202206150300
Diffstat (limited to 'macros/generic')
-rw-r--r--macros/generic/olsak-misc/README2
-rw-r--r--macros/generic/olsak-misc/cropmarks.tex167
2 files changed, 169 insertions, 0 deletions
diff --git a/macros/generic/olsak-misc/README b/macros/generic/olsak-misc/README
index 821a7b7d40..a564097162 100644
--- a/macros/generic/olsak-misc/README
+++ b/macros/generic/olsak-misc/README
@@ -8,6 +8,7 @@ booklet.tex ... re-orders PDF pages and collects them for booklet printing
cnv.tex ... conversion of texts
cnv-pu.tex ... example of usage of cnv.tex --- pdf outlines in Unicode
cnv-word.tex ... example of usage of cnv.tex --- word to word conversion
+cropmarks.tex .. adds crop-marks to arbitrary PDF documents
eparam.tex ... Full expansion during parameter scanning
fun-coffee.tex . generates splotches in the document
openclose.tex .. repairs balanced text between \Open ...\Close pair
@@ -23,6 +24,7 @@ History:
http://petr.olsak.net/ftp/olsak/makra/
<Jun. 2016> ver.1 ... files contributed to CTAN as one "bundle" olsak-misc
<May 2019> ... qrcode: bug fixed
+<Jun. 2022> ... cropmarks.tex added
License:
-------
diff --git a/macros/generic/olsak-misc/cropmarks.tex b/macros/generic/olsak-misc/cropmarks.tex
new file mode 100644
index 0000000000..d098f8144e
--- /dev/null
+++ b/macros/generic/olsak-misc/cropmarks.tex
@@ -0,0 +1,167 @@
+% cropmarks.tex
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Petr Olsak <petr@olsak.net> Jun. 2022
+
+% This macro adds crop-marks to PDF documents and creates new PDF ouput.
+% See the end of this file for usage and more information.
+
+\newdimen\mlenght \newdimen\mthick
+\newdimen\gap \newdimen\lgap
+\newdimen\hmargin \newdimen\vmargin
+\newdimen\overlap
+\newcount\tmpnum
+\newcount\hmiddle \newcount\vmiddle
+
+%% Defaults:
+
+\hmargin=10mm % added left+right margins from the document border to the sheet border
+\vmargin=10mm % added top+bottom margins from the document border to the sheet border
+\mlenght=5mm % lenght of the crop-mark abscisses
+\gap=2mm % distance of crop-mark abscisses from the document corner
+\mthick=.2pt % thickness of the crop-mark abscisses
+\overlap=0mm % document borders can exceed to the crop area by \overlap
+\hmiddle=1 % number of equidistant middle marks in left+right margins
+\vmiddle=1 % number of equidistant middle marks in top+bottom margins
+
+\def\document{name}
+\def\info{}
+
+\newbox\hrul \newbox\vrul
+
+\def\initboxes{
+ \setbox\hrul=\hbox{\vrule width\mlenght height.5\mthick depth.5\mthick}
+ \setbox\vrul=\hbox to0pt{\hss\vrule width\mthick height\mlenght\hss}
+ \ht\hrul=0pt \dp\hrul=0pt
+ \lgap=\gap \advance\lgap by\mlenght
+}
+\def\cropLT{\vbox to0pt{\vss\llap{\copy\hrul\kern\gap\raise\gap\copy\vrul}}}
+\def\cropRT{\vbox to0pt{\vss\rlap{\raise\gap\copy\vrul\kern\gap\copy\hrul}}}
+\def\cropLB{\vbox to0pt{\llap{\copy\hrul\kern\gap\lower\lgap\copy\vrul}\vss}}
+\def\cropRB{\vbox to0pt{\rlap{\lower\lgap\copy\vrul\kern\gap\copy\hrul}\vss}}
+\def\middleT{\vbox to0pt{\vss\copy\vrul\kern\gap}}
+\def\middleB{\vbox to0pt{\kern\gap\copy\vrul\vss}}
+\def\middleL{\llap{\copy\hrul\kern\gap}}
+\def\middleR{\rlap{\kern\gap\copy\hrul}}
+
+% \cropmarks{box}
+% creates a dimension-less crop marks around the box and prints the box with them:
+
+\def\cropmarks#1{%
+ \vbox{\offinterlineskip
+ \setbox0=\hbox{\kern-\overlap#1\kern-\overlap}
+ \dimen0=\wd0 \dimen1=\ht0 \advance\dimen1 by\dp0 \advance\dimen1 by-2\overlap
+ \kern-\overlap
+ \box0
+ \kern-\overlap
+ \vbox to0pt{
+ \kern-\dimen1
+ \ifx\info\empty \else
+ \vbox to0pt{\vss\hbox{\quad\strut\info}\kern\gap}\fi
+ \hbox to\dimen0{\cropLT\hss \vmiddleloop\middleT \cropRT}
+ \vss \tmpnum=0
+ \loop \ifnum\tmpnum<\hmiddle
+ \advance\tmpnum by1
+ \hbox to\dimen0{\middleL\hss\middleR}%
+ \vss \repeat
+ \hbox to\dimen0{\cropLB\hss\vmiddleloop\middleB \cropRB}
+ }
+}}
+\def\vmiddleloop#1{\tmpnum=0
+ \loop
+ \ifnum\tmpnum<\vmiddle
+ \advance\tmpnum by1
+ #1\hss
+ \repeat
+}
+\def\docropmarks{%
+ \initboxes
+ \setbox0=\hbox{\pdfximage {\document.pdf}\pdfrefximage\pdflastximage}
+ \pdfpagewidth=\dimexpr\wd0-2\overlap+2\hmargin \relax
+ \pdfpageheight=\dimexpr\ht0+\dp0-2\overlap+2\vmargin \relax
+ \hoffset=\hmargin \advance\hoffset by-\pdfhorigin
+ \voffset=\vmargin \advance\voffset by-\pdfvorigin
+ %
+ \pageno=1
+ \shipout\cropmarks{\box0}
+ \loop
+ \ifnum\pageno<\pdflastximagepages
+ \advance\pageno by1
+ \shipout\cropmarks
+ {\hbox{\pdfximage page\pageno{\document.pdf}\pdfrefximage\pdflastximage}}
+ \repeat
+ \end
+}
+\let\\=\undefined % for better elimination of bad command line syntax
+
+\frenchspacing
+\def\othe #1{\ifnum#1<10 0\fi\the#1}
+\def\today {\the\year-\othe\month-\othe\day} % you can re-define this format
+\ifx\optexversion\undefined \catcode`\_=12 \fi % names can include _ character
+
+\endinput
+
+
+About the cropmarks.tex macro
+=============================
+
+This macro adds crop-marks to arbitrary PDF documents. The PDF document can
+be created by LaTeX or OpTeX or ConTeXt or something else. Then use
+this plain TeX macro for creating additional crop-marks.
+
+Prepare following TeX file. Its name can be crop.tex, for example, but its
+name cannot be cropmarks.tex, becuase this is the macro file.
+
+--------------------------------
+
+\input cropmarks
+
+\def\document{name} % the name of the PDF file without extension
+\def\info{} % info text printed in the top (in crop area)
+
+\hmargin=10mm % added left+right margins from the document border to the sheet border
+\vmargin=10mm % added top+bottom margins from the document border to the sheet border
+\mlenght=5mm % lenght of the crop-mark abscisses
+\gap=2mm % distance of crop-mark abscisses from the document corner
+\mthick=.2pt % thickness of the crop-mark abscisses
+\overlap=0mm % document borders can exceed to the crop area by \overlap
+\hmiddle=1 % number of equidistant middle marks in left+right margins
+\vmiddle=1 % number of equidistant middle marks in top+bottom margins
+
+\docropmarks % reads \document.pdf and creates new PDF file
+
+---------------------------------
+
+and run it by:
+
+ pdftex crop
+
+or
+
+ optex crop
+
+Of course, you can set different values than these default ones mentioned
+in the example.
+
+The information text defined in the \info macro can include \document.pdf
+(document name), \folio (page number), \today (current date). For example,
+you can try:
+
+ \def\info{\tt [\document.pdf] -- \today\ -- page: \folio}
+
+You can run cropmarks without creating the crop file directly from command line:
+
+ pdftex cropmarks '\def\document{name} \docropmarks'
+
+This command reads name.pdf and creates cropmarks.pdf as the output.
+You can have your own configuration of mentioned values in cropmaks.cfg file
+and run
+
+ pdftex cropmaks '\input cropmarks.cfg \def\document{name} \docropmarks'
+
+You can use optex instead pdftex, of course.
+
+If you want to put more pages to one sheet then you have to do this job
+first and then you can add cropmarks for whole sheets. Use another software
+(or your TeX macro or use OpTeX trick 0088) for creating sheets and create a
+new PDF document. Then set appropriate number of middle marks and read this
+new document with sheets at input side when you are using cropmarks.tex