Tag: file
Printing multi-page duplex documents
by Mostafa on Oct.18, 2009, under How To ..., Linux, Software
The psnup tool can be used to place multiple pages on each sheet of a document. E.g., the following command places two pages from the input file into each sheet of the output:
$ psnup -l -2 input.ps output.ps
While psnup is excellent for quick “N-up” conversion jobs, it doesn’t provide much control over the layout. The pstops utility on the other hand allows for fine grained scale, rotation and placement settings for each page that goes into a sheet of the output. The command syntax is a bit more complicated on account of the page specification strings that must now be provided. The following example shows a typical command needed to prepare a document for duplex printing with two pages on each side of a sheet:
$ pstops -pa4 \ '4:0L@0.8(21cm,-1cm)+1L@0.8(21cm,12.55cm),2R@0.8(0,29.85cm)+3R@0.8(0,16.25cm)' \ input.ps output.ps
The command is best understood by referring to the relevant section from the manpage:
Pstops rearranges pages from a PostScript document, creating a new
PostScript file. The input PostScript file should follow the Adobe
Document Structuring Conventions. Pstops can be used to perform a
large number of arbitrary re-arrangements of Documents, including
arranging for printing 2-up, 4-up, booklets, reversing, selecting front
or back sides of documents, scaling, etc.
pagespecs follow the syntax:
pagespecs = [modulo:]specs
specs = spec[+specs][,specs]
spec = [-]pageno[L][R][U][@scale][(xoff,yoff)]
modulo is the number of pages in each block. The value of modulo should
be greater than 0; the default value is 1. specs are the page specifi-
cations for the pages in each block. The value of the pageno in each
spec should be between 0 (for the first page in the block) and modulo-1
(for the last page in each block) inclusive. The optional dimensions
xoff and yoff shift the page by the specified amount. xoff and yoff
are in PostScript’s points, but may be followed by the units cm or in
to convert to centimetres or inches, or the flag w or h to specify as a
multiple of the width or height. The optional parameters L, R, and U
rotate the page left, right, or upside-down. The optional scale param-
eter scales the page by the fraction specified. If the optional minus
sign is specified, the page is relative to the end of the document,
instead of the start.
If page specs are separated by + the pages will be merged into one
page; if they are separated by they will be on separate pages. If
there is only one page specification, with pageno zero, the pageno may
be omitted.
The shift, rotation, and scaling are performed in that order regardless
of which order they appear on the command line.
Cropping a PDF Document
by Mostafa on Jul.31, 2006, under How To ..., LaTeX, Software
Easily accomplished using pdftops:
$ pdftops -paperw WIDTH \
-paperh HEIGHT \
-noshrink -expand document.pdf && ps2pdf document.ps
WIDTH and HEIGHT are in points — they basically specify the dimensions of the image to be cropped.
Content is extracted from the center of the page. This technique is specially useful as a bypass for using psfrag with pdfLatex:
- Save EPS figure with TAGS
- Create a very simple tex document that simply includes the figure (centered) with psfrag replacements and run latex -> dvips -> ps2pdf
- Follow the step above to crop out the figure.
The cropped out figure will have the TAGS replaced and be in PDF format — ready to be used with pdfLatex!
UPDATE [16 July 2009] It looks like pdfcrop might actually be a better option:
$ pdfcrop --help
PDFCROP 1.5, 2004/06/24 - Copyright (c) 2002, 2004 by Heiko Oberdiek.
Syntax: pdfcrop [options] <input[.pdf]> [output file]
Function: Margins are calculated and removed for each page in the file.
Options: (defaults:)
--help print usage
--(no)verbose verbose printing (false)
--(no)debug debug informations (false)
--gscmd <name> call of ghostscript (gs)
--pdftexcmd <name> call of pdfTeX (pdftex)
--margins "<left> <top> <right> <bottom>" (0 0 0 0)
add extra margins, unit is bp. If only one number is
given, then it is used for all margins, in the case
of two numbers they are also used for right and bottom.
--(no)clip clipping support, if margins are set (false)
--(no)hires using `%%HiResBoundingBox' (false)
instead of `%%BoundingBox'
--papersize <foo> parameter for gs's -sPAPERSIZE=<foo>,
use only with older gs versions <7.32 ()
Examples:
pdfcrop --margins 10 input.pdf output.pdf
pdfcrop --margins '5 10 5 20' --clip input.pdf output.pdf
The tool comes as a part of the ‘tetex’ package.


