Table of Contents

Class Stamp

Namespace
PDFjet.NET
Assembly
PDFjet.dll

Content that is drawn once with the path and text methods of this class, written to the document as a PDF form XObject by Complete, and placed on pages with DrawOn, at a location, a rotation and a scale, as a Container is.

What a stamp is good at: the content is in the file once, and each placement is the q, the transform and the Do that name it -- 83 bytes for a 200 by 50 point box with two lines of text, against the 367 a Container writes into every page for the same drawing. From the fourth page on the stamp is the smaller of the two: over 100 pages it saves 12,855 bytes of a 104,530 byte file, and over 500 pages 66,052 of 275,553. The whole stamp is one structure element in a PDF/UA document, with the alternate description, the language and the actual text it is given, which is what a logo or a watermark wants.

What it costs: a stamp draws with the methods of this class -- MoveTo, LineTo, CurveTo, DrawRect, FillRect and DrawText -- and holds no drawable of its own, so it has no images, no annotations, no tables and no barcodes. Its text needs a font that is embedded in the document: a core font and a CJK font are refused, since a stamp has no map from their characters to their glyphs. It has to be completed before it is drawn, and completed once. On fewer than four pages it is the larger of the two, since its XObject costs about 300 bytes of its own.

Use a Container instead to group drawable elements -- Rect, TextLine, Image, Table, a chart, a barcode, an annotation -- that are moved, rotated and scaled together, and to lay a group out once for one page. A container can hold a stamp, so a header written once can be placed inside a group that is rotated with the rest of it.

Please see Example_31.

public class Stamp : IDrawable
Inheritance
Stamp
Implements
Inherited Members

Constructors

Stamp(PDF)

Creates a stamp for the specified document.

public Stamp(PDF pdf)

Parameters

pdf PDF

Methods

AddFont(Font)

Adds a font used by the text on this stamp.

public Stamp AddFont(Font font)

Parameters

font Font

Returns

Stamp

CloseFillAndStrokePath()

Closes, fills and strokes the current path.

public Stamp CloseFillAndStrokePath()

Returns

Stamp

ClosePath()

Closes and strokes the current path.

public Stamp ClosePath()

Returns

Stamp

Complete()

Writes this stamp to the document as a form XObject. Call it once, after drawing the content and before DrawOn.

public void Complete()

CurveTo(float, float, float, float, float, float)

Adds a cubic Bézier curve from the current point to x3, y3, using x1, y1 and x2, y2 as control points.

public Stamp CurveTo(float x1, float y1, float x2, float y2, float x3, float y3)

Parameters

x1 float
y1 float
x2 float
y2 float
x3 float
y3 float

Returns

Stamp

DrawOn(Page)

Draws this stamp on the specified page and returns the x and y coordinates of its bottom right corner.

public float[] DrawOn(Page page)

Parameters

page Page

Returns

float[]

DrawPath(List<Point>, PathOperator)

Draws a path through the points. Control points define Bézier curves. Fewer than two points paint nothing. A path that ends on a control point, whose curve has no end, is refused and nothing of it is drawn.

public void DrawPath(List<Point> path, PathOperator pathOperator)

Parameters

path List<Point>
pathOperator PathOperator

DrawRect(float, float, float, float)

Draws the outline of a rectangle.

public Stamp DrawRect(float x, float y, float w, float h)

Parameters

x float
y float
w float
h float

Returns

Stamp

DrawText(Font, float, float, float, string)

Draws text on this stamp with an embedded font, which the stamp adds to its fonts.

public Stamp DrawText(Font font, float fontSize, float x, float y, string text)

Parameters

font Font
fontSize float
x float
y float
text string

Returns

Stamp

DrawText(TextParameters)

Draws text using the font, font size, location and text in the parameters.

public Stamp DrawText(TextParameters parameters)

Parameters

parameters TextParameters

Returns

Stamp

FillPath()

Fills the current path.

public Stamp FillPath()

Returns

Stamp

FillRect(float, float, float, float)

Draws a filled rectangle.

public Stamp FillRect(float x, float y, float w, float h)

Parameters

x float
y float
w float
h float

Returns

Stamp

LineTo(float, float)

Adds a straight line from the current point to the specified point.

public Stamp LineTo(float x, float y)

Parameters

x float
y float

Returns

Stamp

MoveTo(float, float)

Begins a new path at the specified point.

public Stamp MoveTo(float x, float y)

Parameters

x float
y float

Returns

Stamp

ScaleBy(float)

Scales this stamp around its center when it is placed on a page; 1 is its size.

public Stamp ScaleBy(float factor)

Parameters

factor float

Returns

Stamp

ScaleBy(float, float)

Scales this stamp around its center when it is placed on a page.

public Stamp ScaleBy(float sx, float sy)

Parameters

sx float
sy float

Returns

Stamp

SetActualText(string)

Sets the actual text for this stamp.

public Stamp SetActualText(string actualText)

Parameters

actualText string

Returns

Stamp

SetAltDescription(string)

Sets the alternate description of this stamp.

public Stamp SetAltDescription(string altDescription)

Parameters

altDescription string

Returns

Stamp

SetFillColor(int)

Sets the fill color for the content drawn after it, as a 0xRRGGBB value. Color.transparent leaves it unchanged.

public Stamp SetFillColor(int color)

Parameters

color int

Returns

Stamp

SetFillColor(float[])

Sets the fill color for the content drawn after it, from an array of red, green and blue values.

public Stamp SetFillColor(float[] rgbColor)

Parameters

rgbColor float[]

Returns

Stamp

SetLanguage(string)

Sets the language of this stamp, used for accessibility.

public Stamp SetLanguage(string language)

Parameters

language string

Returns

Stamp

SetLocation(float, float)

Sets the location of the top left corner of this stamp on the page.

public Stamp SetLocation(float x, float y)

Parameters

x float
y float

Returns

Stamp

SetRotation(float)

Rotates this stamp around its center: clockwise for a positive angle, as every rotation in PDFjet turns, and counterclockwise for a negative angle.

public Stamp SetRotation(float degrees)

Parameters

degrees float

The rotation angle in degrees.

Returns

Stamp

SetSize(float, float)

Sets the size of this stamp, before anything is drawn on it: its y runs down from its top.

public Stamp SetSize(float width, float height)

Parameters

width float
height float

Returns

Stamp

SetStrokeColor(int)

Sets the stroke color for the content drawn after it, as a 0xRRGGBB value. Color.transparent leaves it unchanged.

public Stamp SetStrokeColor(int color)

Parameters

color int

Returns

Stamp

SetStrokeColor(float[])

Sets the stroke color for the content drawn after it, from an array of red, green and blue values.

public Stamp SetStrokeColor(float[] rgbColor)

Parameters

rgbColor float[]

Returns

Stamp

SetStrokeWidth(float)

Sets the stroke width for the content drawn after it.

public Stamp SetStrokeWidth(float width)

Parameters

width float

Returns

Stamp

StrokePath()

Strokes the current path.

public Stamp StrokePath()

Returns

Stamp