[tex-live] How to set TrimBox, BleedBox in LaTeX + dvips

Axel Strübing axel.struebing at freenet.de
Sat Oct 3 14:52:47 CEST 2009


Dear all,

the cited question is from an old entry on the pdftex list. In my opinion an 
answer is better placed here.

I did come across the very same problem David asked there.

We can achieve this by means of the following pdfmark command '[ {ThisPage} << 
/#1 [#2] >> /PUT pdfmark'. Because all box entries besides CropBox have to be 
specified for every single page in its pdfdict this lead to using the bop-hook 
from dvips. I do not know if a mechanism is desired for setting different 
values for different pages (this is impossible with my implementation).

I would be glad if someone has any suggestions or comments about the following 
two macros.

The first collects the box specifications in a macro. 
\let\@processPdfBoxSpec\@empty%
\newcommand{\@setPdfBox}[2]{%
  \xdef\@processPdfBoxSpec{%
    [ {ThisPage} << /#1 [#2] >> /PUT pdfmark
    \@processPdfBoxSpec
  }%
}

The second writes a \special and defines the postscript procedure that calls 
the pdfmark commands that inserts the box specifications into the 
pagedictionary. Furthermore the old definition of bop-hook (if any) is saved 
and bop-hook is defined as the union of the old definition and @setpdfboxes:
\newcommand{\@setPdfBoxes}{%
  \ifx\@processPdfBoxSpec\@empty{\relax}%
  \else%
  {%
  \special{!userdict begin^^J%
    /@setpdfboxes{\@processPdfBoxSpec} def^^J%
    /bop-hook where{pop /@pdfboxbophook /bop-hook load def^^J%
    /bop-hook{ @pdfboxbophook @setpdfboxes } def }{/bop-hook {@setpdfboxes} 
def^^J%
    }ifelse end}%
  }%
\fi%
}%

\@onlypreamble\@setPdfBoxes
\@onlypreamble\@setPdfBox

>
>Dear All,
>
>Can anyone tell that how we can set the TrimBox, BleedBox using LaTeX
>commands or directly in PS file using postscript commands to appear
>same in resulting PDF when viewed in Acrobat.
>
>I understand that in PDFLaTeX one can set this using \pdfpageattr and
>\pdfpagesattr but I want to know that how we can achieve same in LaTeX
>or in resulting PS using postscript command or pdfmarks for the same.

>Regards 
>David 

regards
Axel Strübing




More information about the tex-live mailing list