Stamp

Add a stamp to selected pages of inFile. Have a look at some examples.

The stamp is centered on the page and using description you can configure various aspects like rotation, scaling and opacity. For text based stamps you can also configure font name, font size, fill color and render mode.

Usage

  1. pdfcpu stamp [-v(erbose)|vv] [-pages pageSelection] [-upw userpw] [-opw ownerpw] description inFile [outFile]

You can stamp or watermark inFile exactly once. It is highly recommended to make a backup of inFile before running this command or even better use outFile.


NOTE

In the Adobe world a watermark is text or an image that appears either in front of or behind existing document content, like a stamp comment aka stamp annotation that anybody reading the PDF can open, edit, move around and delete. The difference here is that a watermark is integrated into a PDF page as a fixed element. Within pdfcpu the meaning of these terms is slightly different:

  • stamp is any content that appears in front of the existing page content - sitting on top of everything else on a page

  • watermark is any content that appears behind the existing page content - residing in the page background

where content may be text, an image or a PDF page.


Flags

flagdescriptionrequired
verboseturn on loggingno
vvverbose loggingno
pagespage selectionno
upwuser passwordno
opwowner passwordno

Arguments

namedescriptionrequireddefault
descriptionconfiguration stringyes
inFilePDF input fileyes
outFilePDF output filenoinFile_new.pdf

Description

A configuration string to specify the stamp parameters.

The first entry of the description configures the type. It is one of the following:

  • text string (Use \n for a multiline stamp)
  • image file name
  • PDF file name followed by an optional page number
    parameterdescriptionvaluesdefault
    ffontname, a basefontHelvetica, Times-Roman, CourierHelvetica
    pfontsize in pointsin combination with absolute scaling only24
    sscale factor0.0 < i <= 1.0 followed by optional abs or rel0.5 rel
    ccolor, 3 fill color intensities0.0 <= r,g,b <= 1.0, eg. 1.0, 0.0 0.0 = red0.5 0.5 0.5 = gray
    rrotation angle-180.0 <= i <= 180.00.0
    drender along diagonal1 .. lower left to upper right1
    2 .. upper left to lower right
    oopacity0.0 <= i <= 1.01
    mrender mode0 .. fill0
    1 .. stroke
    2 .. fill & stroke

Only one of rotation and diagonal is allowed.

The following description parameters are for text based stamps only:

  • font name
  • font size
  • color
  • render mode

Default description

  1. 'f:Helvetica, p:24, s:0.5 rel, c:0.5 0.5 0.5, r:0, d:1, o:1, m:0'

The default stamp configuration is:

  • fixed center page position (free positioning will be part of a future release)
  • scale factor 0.5 relative to page dimensions
  • positive rotation along the diagonale from the lower left to the upper right page corner (d:1).
  • fully opaque stamp by defining opacity 1In addition for text based stamps:

  • font name Helvetica

  • font size 24 points
  • fill color grey (0.5 0.5 0.5)
  • render mode fill (m:0)You only have to specify parameters that differ from the default.

Examples

Text Based Stamps

Create a stamp using defaults only:

  1. pdfcpu stamp 'This is a stamp' test.pdf out.pdf

Stamp  - 图1

Create a stamp using scale factor 1:

  1. pdfcpu stamp 'This is a stamp, s:1' test.pdf out.pdf

Stamp  - 图2 Stamp  - 图3

Create a stamp along the second diagonale using scale factor 0.9, default render mode fill and a fill color:

  1. pdfcpu stamp 'This is a stamp, s:.9, d:2, c:.6 .2 .9' test.pdf out.pdf

Stamp  - 图4

Create a stamp with 0 degree rotation using scale factor 0.9 and render mode stroke:

  1. pdfcpu stamp 'This is a stamp, s:.9, r:0, m:1' test.pdf out.pdf

Stamp  - 图5

Create a stamp with a counterclockwise rotation of 45 degrees using scale factor 1, render mode fill & stroke and a fill color:

  1. pdfcpu stamp 'This is a stamp, s:1, r:45, m:2, c:.2 .7 .9' test.pdf out.pdf

Stamp  - 图6

Create a stamp with default rotation, using scale factor 1, font size 48, default render mode fill, a fill color and increasing opacity from 0.3 to 1. By setting an opacity < 1 you can fake a watermark. This may be useful in scenarios where pdfcpu watermark does not produce satisfying results for a particular PDF file:

  1. pdfcpu stamp 'Draft, p:48, s:1, c:.8 .8 .4, o:.3' test.pdf out1.pdf
  2. pdfcpu stamp 'Draft, p:48, s:1, c:.8 .8 .4, o:0.6' test.pdf out2.pdf
  3. pdfcpu stamp 'Draft, p:48, s:1, c:.8 .8 .4, o:1' test.pdf out3.pdf

Stamp  - 图7 Stamp  - 图8 Stamp  - 图9

Image Based Stamps

Create a stamp using defaults only:

  1. pdfcpu stamp 'pic.jpg' test.pdf out.pdf

Stamp  - 图10

Create a stamp using 0 degree rotation and relative scaling of 1.0:

  1. pdfcpu stamp 'pic.jpg, s:1 rel, r:0' test.pdf out.pdf

Stamp  - 图11

PDF Based Stamps

Create a stamp using defaults only. This will apply page 1 of some.pdf:

  1. pdfcpu stamp 'some.pdf' test.pdf out.pdf

Stamp  - 图12

Create a stamp using defaults and page 2 of some.pdf, apply a 0 degree rotation and 0.3 relative scaling:

  1. pdfcpu stamp 'some.pdf:2, r:0, s:.3' test.pdf out.pdf

Stamp  - 图13