<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">%%% Self-documented example of pdf-trans.tex usage (pdfTeX)
%%% P.Jackowski@gust.org.pl

\input pdf-trans

\pdfdecimaldigits=3
\pdfcompresslevel=0               % to see what is happening

% Some configuration
% \enablefractangle               % float angles support (deafult)
% \disablefractangle              % integer only (old behaviour)
% \enablebpround                  % round \pdfliteral dimens to \pdfdecimanligits (default)
% \disablebpround                 % disable rounding (old behaviour)
% \let\tobp\roundfixedbp          % calculate \pdfliteral dimens with fixed precision (risky)
\setbpround\pdfdecimaldigits      % fix rounding precision (speed-up things)

\font\F=qx-lmr10    at 120pt
\font\f=qx-lmr10    at 60pt
\font\T=qx-lmtt10   at 15pt
\font\tt=qx-lmtt10  at 10pt
\font\ttt=qx-lmtt10 at 8pt

\pdfpagewidth=165mm
\pdfpageheight=120mm
\pdfhorigin=10mm
\pdfvorigin=10mm
\hsize=\dimexpr\pdfpagewidth-2\pdfhorigin
\vsize=\dimexpr\pdfpageheight-2\pdfvorigin

\parindent=0pt
\nopagenumbers

\ifx\pdfminorversion\undefined
 \pdfoptionpdfminorversion=5
\else
 \pdfminorversion=5
\fi

\def\saveobjnum#1{\expandafter\edef\csname objnum:#1\endcsname{\the\pdflastobj\space 0 R}}
\def\objnum#1{\csname objnum:#1\endcsname}
\immediate\pdfobj{&lt;&lt; /Type /OCG /Name (box content before) &gt;&gt;}\saveobjnum{1}
\immediate\pdfobj{&lt;&lt; /Type /OCG /Name (box outline before) &gt;&gt;}\saveobjnum{2}
\immediate\pdfobj{&lt;&lt; /Type /OCG /Name (box content after) &gt;&gt;}\saveobjnum{3}
\immediate\pdfobj{&lt;&lt; /Type /OCG /Name (box outline after) &gt;&gt;}\saveobjnum{4}
\immediate\pdfobj{&lt;&lt; /Type /OCG /Name (final bounding box) &gt;&gt;}\saveobjnum{5}

\edef\pdfpagerc{/Properties &lt;&lt; /OC1 \objnum{1} /OC2 \objnum{2} /OC3 \objnum{3} /OC4 \objnum{4} /OC5 \objnum{5}&gt;&gt;}
\expandafter\pdfpageresources\expandafter{\pdfpagerc}
\edef\pdfcatalogoc{%
/OCProperties
&lt;&lt;
 /OCGs [\objnum{1} \objnum{2} \objnum{3} \objnum{4} \objnum{5}]
 /D &lt;&lt; /Order [\objnum{1} \objnum{2} \objnum{3} \objnum{4} \objnum{5}]
       /OFF   [\objnum{2} \objnum{4}]
    &gt;&gt;
&gt;&gt;}
\expandafter\pdfcatalog\expandafter{\pdfcatalogoc}% \pdfcatalog expands anyway

\newbox\qbox

\def\defaultgs{\pdfliteral direct{.5 w 1 j 1 J}}

\def\boxbe{\boxshow{/OC /OC2 BDC 0.3 G}         {[2 2] 1 d}{EMC} \boxgs{/OC /OC1 BDC 2 Tr 0.7 g}{EMC}}
\def\boxaf{\boxshow{/OC /OC4 BDC 1.0 0.6 0.0 RG}{[2 2] 1 d}{EMC} \boxgs{/OC /OC3 BDC 2 Tr 1.0 0.8 0.0 rg}{EMC}}
\def\boxbb{\boxshow{/OC /OC5 BDC 0.7 0.0 0.0 RG}{[2 2] 1 d}{EMC}}

\def\bookmark#1{%
 \pdfoutline goto page\pageno {/Fit}{\getbookmark#1\relax}}

\def\getbookmark#1#2\relax{\string\\\expandafter\gobbleone\string#1}
\def\gobbleone#1{}

\def\test/#1/#2/{%
 \bookmark{#2}\defaultgs
 \vbox to4cm{\vss
  Yo\boxbe\copy\qbox\kern-\wd\qbox
 \boxbb#1\boxaf\copy\qbox a}\vfill
 {\tt\detokenize{#2 &lt;box&gt;}}\medskip{\ttt\detokenize{#1}}\eject}

\def\rawtest/#1/#2/{%
 \bookmark{#2}\defaultgs
 \vbox to4cm{\vss
  Yo#1\copy\qbox a}\vfill
 {\tt\detokenize{#2 &lt;box&gt;}}\medskip{\ttt\detokenize{#1}}\eject}

%%%

\T\defaultgs

box tra\boxflipy\boxgs{1.0 0.8 0.0 rg}{}\hbox{N}%
sfo\boxrotatec{15}\boxgs{1.0 0.8 0.0 rg}{}\hbox{R}%
mation\boxflipx\boxgs{1.0 0.8 0.0 rg}{}\hbox{S} in
\boxgs{0.7 g}{}\hbox{pdf-trans.tex}

\vskip0pt plus 4fil
\setbox\qbox\hbox{\f g}
\ttt
\leavevmode\boxbe\copy\qbox            \quad before
\vfil
\leavevmode\boxaf\copy\qbox            \quad after
\vfil
\leavevmode\boxbb\boxphantom\copy\qbox \quad bounding box

\line{\hfill\boxrevolveleft\boxsmash\hbox{P.Jackowski@gust.org.pl}}
\pdfoutline goto page\pageno {/Fit}{pdf-trans.tex}

\eject

%%%

\F\setbox\qbox\hbox{g}

\test/\boxflipx   /\boxflipx/
\test/\boxflipy   /\boxflipy/
\test/\boxflipxy  /\boxflipxy/
\test/\boxflipbase/\boxflipbase/
\test/\bboxtrans\boxflipbase/\bboxtrans{&lt;trans&gt;}/
\test/\cboxtrans\boxflipbase/\cboxtrans{&lt;trans&gt;}/

\test/\boxtranslate{3mm}{2mm}/\boxtranslate{&lt;dimexpr&gt;}{&lt;dimexpr&gt;}/

\test/\boxrevolveleft /\boxrevolveleft/
\test/\boxrevolveright/\boxrevolveright/

\test/\boxrotate{394.7}/\boxrotate{&lt;angle&gt;}/
\test/\boxrotatexy{34.2}{\wd\transbox}{\ht\transbox}
     /\boxrotatexy{&lt;angle&gt;}{&lt;dimexpr&gt;}{&lt;dimexpr&gt;}/
\test/\boxrotatec{90}/\boxrotatec{&lt;angle&gt;}/

\test/\boxrotatebbl{-34.1}/\boxrotatebbl{&lt;angle&gt;}/
%\test/\boxrotatebbl{-34.2}/\boxrotatebbl{&lt;angle&gt;}/
\test/\boxrotatebbr{-34.2}/\boxrotatebbr{&lt;angle&gt;}/

\test/\boxslantx{15.2}      /\boxslantx{&lt;angle&gt;}/
\test/\boxslanty{25.3}      /\boxslanty{&lt;angle&gt;}/
%\test/\boxslantxy{15}{25} /\boxslantxy{&lt;angle&gt;}{&lt;angle&gt;}/

\test/\boxslantbbl{15}{25}/\boxslantbbl{&lt;angle&gt;}{&lt;angle&gt;}/
\test/\boxslantbbr{15}{25}/\boxslantbbr{&lt;angle&gt;}{&lt;angle&gt;}/

\test/\boxscalex{75}      /\boxscalex{&lt;numexpr&gt;}/
\test/\boxscaley{75}      /\boxscaley{&lt;numexpr&gt;}/
\test/\cboxtransoff\boxscalexy{150}{75}/\boxscalexy{&lt;numexpr&gt;}{&lt;numexpr&gt;}/
\test/\bboxtransoff\boxscale{75}       /\boxscale{&lt;numexpr&gt;}/

\test/\boxscalexto{.5in+.1cm} /\boxscalexto{&lt;dimexpr&gt;}/
\test/\boxscaleyto{.5in+.1cm} /\boxscaleyto{&lt;dimexpr&gt;}/
\test/\boxscalexyto{.5in+.1cm}{1in/2}/\boxscalexyto{&lt;dimxpr&gt;}{&lt;dimexpr&gt;}/
\test/\boxscalehtto{.5in+.1cm}/\boxscalehtto{&lt;dimexpr&gt;}/
\test/\boxscaledpto{.5in+.1cm}/\boxscaledpto{&lt;dimexpr&gt;}/

\test/\boxuniscalexto{.5in+.1cm} /\boxuniscalexto{&lt;dimexpr&gt;}/
\test/\boxuniscaleyto{.5in+.1cm} /\boxuniscaleyto{&lt;dimexpr&gt;}/
\test/\boxuniscalehtto{.5in+.1cm}/\boxuniscalehtto{&lt;dimexpr&gt;}/
\test/\boxuniscaledpto{.5in+.1cm}/\boxuniscaledpto{&lt;dimexpr&gt;}/

\test/\boxextscale{2mm}{5mm}{8mm}/\boxextscale{&lt;dimexpr&gt;}{&lt;dimexpr&gt;}{&lt;dimexpr&gt;}/
\test/\boxextscaleto{3cm}{1cm}{2cm}/\boxextscaleto{&lt;dimexpr&gt;}{&lt;dimexpr&gt;}{&lt;dimexpr&gt;}/

\test/\boxexts{3mm}{3mm}{5mm}{5mm}
      /\boxexts{&lt;dimexpr&gt;}{&lt;dimexpr&gt;}{&lt;dimexpr&gt;}{&lt;dimexpr&gt;}/

\test/\boxextents{2mm}{4mm}{6mm}{8mm}
      /\boxextents{&lt;dimexpr&gt;}{&lt;dimexpr&gt;}{&lt;dimexpr&gt;}{&lt;dimexpr&gt;}/

% obsolete
%\test/\boxresizeto{}{3cm}{2cm}
%      /\boxresizeto{&lt;dimexpr&gt;}{&lt;dimexpr&gt;}{&lt;dimexpr&gt;}/
%\test/\boxresize{-3mm}{}{-2mm} /\boxresize{&lt;dimexpr&gt;}{&lt;dimexpr&gt;}{&lt;dimexpr&gt;}/

\test/\boxxformspec resources{\the\pdfpageresources} \boxxform\boxresizeto{11mm}{8mm}{3mm}
     /\boxxformspec resources{/Foo /Bar} \boxxform/

\test/\boxclip\boxresizeto{}{8mm}{3mm} /\boxclip/

\test/\boxmoveleft{.3\wd\transbox}/\boxmoveleft{&lt;dimexpr&gt;}/
\test/\boxmoveright{.3\wd\transbox}/\boxmoveright{&lt;dimexpr&gt;}/
\test/\boxlower{\dp\transbox}/\boxlower{&lt;dimexpr&gt;}/
\test/\boxraise{\dp\transbox}/\boxraise{&lt;dimexpr&gt;}/
\test/\boxbaselineat{50}/\boxbaselineat{&lt;numexpr&gt;}/

% \rawtest/\boxphantom        /\boxphntom/
\rawtest/\boxinfo\boxsh/\boxinfo/
\rawtest/\boxshow{0 1 0 RG}{[1 1]0 d}{}
        /\boxshow{&lt;gsspec&gt;}{&lt;gsspec&gt;}{&lt;gsspec&gt;}/
% \rawtest/\boxsh/\boxsh/
\rawtest/\boxmarkers{-12pt}{3pt}{1 0 0 RG 1 J}/\boxmarkers{&lt;dimexpr&gt;}{&lt;dimexpr&gt;}{&lt;gsspec&gt;}/

\rawtest/\boxpath{3 w .7 0 0 rg 1 .8 0 RG}{B}\bboxtrans{\boxextscale{3mm}{3mm}{3mm}}\boxmoveright{3mm}
        /\boxpath{&lt;gsspec&gt;}{&lt;paintop&gt;}/
\rawtest/\boxroundpath{4mm}{3 w .7 0 0 rg 1 .8 0 RG}{B}\boxextent{3mm}
        /\boxroundpath{&lt;dimexpr&gt;}{&lt;gsspec&gt;}{&lt;paintop&gt;}/
\rawtest/\boxedgypath{4mm}{3 w .7 0 0 rg 1 .8 0 RG}{B}\boxextent{3mm}
        /\boxedgypath{&lt;dimexpr&gt;}{&lt;gsspec&gt;}{&lt;paintop&gt;}/

%%%

\ttt
Each transformation expands to &lt;box&gt; (\string\hbox\ in most cases).\par
Each transformation must be followed by a &lt;box&gt;.\bigskip

&lt;box&gt; states for any kind of \TeX\ box; \string\hbox,
                                        \string\vbox,
                                        \string\vtop,
                                        \string\box,
                                        \string\copy\par

&lt;trans&gt; is a list of box transformations   \par
&lt;dimexpr&gt; states for dimen in eTeX form    \par
&lt;numexpr&gt; states for integer in eTeX form  \par
&lt;angle&gt; is an integer or float-like string \par
&lt;gsspec&gt; is a literal pdf content stream   \par
&lt;paintop&gt; means pdf painting operator (S, f, B, W...)\par

\bigskip

Some extra macros:\par
\def\type#1{{\detokenize{#1}}}
\type{\tobp{&lt;dimexpr&gt;}} returns PDF dimen (big points with no unit) \par
\type{\enablebpround} makes \type{\tobp} rounding to \type{\pdfdecimaldigits} (equivalent to \type{\roundbp}) \par
\type{\setbpround{&lt;0..4&gt;}} makes \type{\tobp} rounding to &lt;0..4&gt; digits (equivalent to \type{\roundbpto{&lt;0..4&gt;}}) \par
\type{\disablebpround} turns off rounding (equivalent to \type{\asbp}) \par


\bigskip
See the code for more.

\end
</pre></body></html>