PSTricks - Graphics for T<span class="e">e</span>X and L<span class="a">a</span>T<span class="e">e</span>X

Welcome to the PSTricks web site

TUG logo

Main page

Bug list
Doc errors
2D Gallery
3D Gallery
Search CTAN:
United Kingdom



Extended translation of the the 5th edition


the 7th edition, total of 960 colored pages


2nd edition, 212 pages, includes 32 color pages










2 a5 on one a4 page |  a4 to a5 conversion from PostScript to PDF |  Automatic export |  avi Videos as included files | 
Bibliography hrefs |  Bookmark | 
Color table |  Color and pagebreak |  Cropping whitespace | 
documentation |  draftcopy watermark | 
Image as a hyperref |  Extracting Images from a PDF file | 
Fonts |  Forms in a pdf Document | 
Graphics Quality | 
hyperref-package | 
Index hrefs |  Insert pdf pages of another document | 
MiKTeX | 
Papersize and pdflatex |  pdftricks |  PDF->ASCII |  pdflatex and Papersize |  pdftk (program) |  PSTricks image as a hyperref | 
Two a5 on one a4 page | 
Watermark |  Whitespace | 

Links to docs (related to PDF)

Cropping whitespace of a pdf page

Inserting a single or several pdf pages into another document is possible with the well known \inlcudegraphics macro. To cut the whitespace around the text one can use the program pdfcrop, available on CTAN. It is important that the cropped pdf document has a \pagestyle{empty}, otherwise the pagenumber is still there.

With the following script one can export all pages of a pdf file into single cropped pdf files.
# Michael Niedermair 2005
echo ${name}
pdftk ${name}.pdf burst
for file in pg_[0-9][0-9][0-9][0-9].pdf
    nrs=${nr:1:3} --clip ${file} ${name}_${nrs}.pdf
    rm -f ${file}
rm -f ${name}.pdf
rm -f doc_data.txt

Another possibility is to use the package pdfpages, which allows to insert pdf pages of another document. For more informations read the package documentation or go here.


To get a bookmark you can use
\pdfbookmark[0]{My Chapter}{myAnchorName}
0: Level (0=chapter, 1=section, 2=subsection, ...)
"My Chapter": Text
"myAnchorName": anything which hyperref can use for the anchor name.


To get a watermark for PDF document you cannot use packages which have a solution with PostScript commands (like the draftcopy package). Use the pdfdraftcopy or the following code in your preamble.

\pdfannot width \wd\MyBox height \ht\MyBox depth \dp\MyBox{
/Subtype /Link
/A <<
  /S /Launch
  /F (#2)

>> %/Border [16 16 0]


Hey, \StartApp{Klick mich!}{movie.mpeg}
Also have a look at easymovie.sty.

By default pdflatex converts references (figure/table/equation-numbers) to links, which includes only the number and not the forgoing word like figure/table/Equation. To get this in the link too, write
\hyperref[bar]{figure (\ref*{bar})}
where bar is a label in any figure environment.


a4 to a5 conversion from PostScript to PDF
To get a a5-format pdf-output with ps2pdf from a a4 PostScript doc run
psresize -Pa4 -pa5 | ps2pdf -sPAPERSIZE=a5 - file_out.pdf

Graphics Quality
To get better Graphics conversion from eps to pdf you can try some of the following options:

For ps2pdf:
For epstopdf:

Font Substitution
To get a better output for pdf files substitute the fonts with
or, if you do not have the lm fonts installed:
\usepackage{mathptmx}% instead of package times
\usepackage[scaled=0.9]{helvet} % or [scaled=0.92], if you like
\usepackage[scaled=0.92]{beramono}% do _not_ use courier

Forms in a PDF Document
Download the TeX-demofile from CTAN and run it with
pdflatex testform.tex
than you'll see in the output testfile.pdf what forms are possible for pdf.

Convert Files to pdf
If you have a lot of files to convert from any type to pdf use the following bash command, which makes life easier, because it converts all files with extension "eps":
for FILE in *.eps ; do epstopdf $FILE ; done
You need the program eostopdf, which should be part of your local TeX Installation.

Insert whole a4 pages or two a5 on one a4 page
in latex preamble
package maybe part of your local tex-installation or available at CTAN. In the text write for example:
\includepdf[pages={1-10}, nup=2, scale=1.414]{a5doc.pdf}
if you want to insert the pages 1-10 of the pdf-document a5doc.pdf in your actual document.

For a single pdf page you can also use:
\includegraphics[page={5}, scale=1.414]{a5doc.pdf}
it knows the optional argument page.

pdfimages -f 1 file.pdf DirForTheImages
extract all images in the pdf-file. with option -j you can save them as jpegs, otherwise by default ppm or pbm - format (a good choice).

pdftotext file.pdf file.txt
convert all to text.

when the pdf-file has some scanned-text, which is saved as image, you can convert these from pbm to tiff and than running an OCR-program.

In case you're wondering where to get pdfimages and pdftotext, they're part of xpdf.
pdftk, a pdf toolkit.


Merge Two or More PDFs into a New Document

pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf

or (Using Handles):

pdftk A=1.pdf B=2.pdf cat A B output 12.pdf

or (Using Wildcards):

pdftk *.pdf cat output combined.pdf

Split Select Pages from Multiple PDFs into a New Document

pdftk A=one.pdf B=two.pdf cat A1-7 B1-5 A8 output combined.pdf

Rotate the First Page of a PDF to 90 Degrees Clockwise

pdftk in.pdf cat 1E 2-end output out.pdf

Rotate an Entire PDF Document's Pages to 180 Degrees

pdftk in.pdf cat 1-endS output out.pdf

Encrypt a PDF using 128-Bit Strength (the Default) and Withhold All Permissions (the Default)

pdftk mydoc.pdf output mydoc.128.pdf owner_pw foopass

Same as Above, Except a Password is Required to Open the PDF

pdftk mydoc.pdf output mydoc.128.pdf owner_pw foo user_pw baz

Same as Above, Except Printing is Allowed (after the PDF is Open)

pdftk mydoc.pdf output mydoc.128.pdf owner_pw foo user_pw baz allow printing

Decrypt a PDF

pdftk secured.pdf input_pw foopass output unsecured.pdf

Join Two Files, One of Which is Encrypted (the Output is Not Encrypted)

pdftk A=secured.pdf mydoc.pdf input_pw A=foopass cat output combined.pdf

Uncompress PDF Page Streams for Editing the PDF Code in a Text Editor

pdftk mydoc.pdf output mydoc.clear.pdf uncompress

Repair a PDF's Corrupted XREF Table and Stream Lengths (If Possible)

pdftk broken.pdf output fixed.pdf

Burst a Single PDF Document into Single Pages and Report its Data to doc_data.txt

pdftk mydoc.pdf burst

Report on PDF Document Metadata, Bookmarks and Page Labels

pdftk mydoc.pdf dump_data output report.txt

local time: Wed Jun 16 04:07:40 CEST 2021 ; file is: 421.366759259259 days old
contact webmaster _at_