Table of Contents

Class Container

Namespace
PDFjet.NET
Assembly
PDFjet.dll

A group of drawable elements that are moved, rotated and scaled together: shapes, text, images, annotations, stamps and nested containers.

What a container is good at: it takes anything that implements IDrawable, so a group can hold an Image, a Table, a chart, a barcode, a link or another annotation, and each element keeps everything it can do. Each element also tags itself in a PDF/UA document, so a TextLine in a container is a paragraph of its own and an Image is a figure with its alternate description. Laying a group out once and placing it, rotated or scaled, is what it is for; elements that have no rotation of their own get one this way.

What it costs: the elements are drawn into the page on every DrawOn, so a container on 100 pages writes its drawing 100 times over.

Use a Stamp instead for content that repeats on many pages -- a header, a footer, a logo, a watermark -- which is written once as a form XObject and placed with a few bytes. Of a 200 by 50 point box with two lines of text, a container writes 367 bytes into every page and a stamp 83, so the stamp is the smaller of the two from the fourth page on: over 100 pages it saves 12,855 bytes of a 104,530 byte file, and over 500 pages 66,052 of 275,553. On one page the stamp is the larger, since its XObject costs about 300 bytes of its own, and it draws only paths and text in an embedded font.

Please see Example_42 and Example_31.

public class Container : IDrawable
Inheritance
Container
Implements
Inherited Members

Constructors

Container(float, float)

Creates a new container with the specified width and height. The container is initialized with:

  • Rotation set to 0 degrees
  • Scaling factors set to 1.0 for both axes
  • An empty list of drawable elements
public Container(float width, float height)

Parameters

width float

The width of the container.

height float

The height of the container.

Methods

Add(IDrawable)

Adds a drawable element to this container.

public Container Add(IDrawable element)

Parameters

element IDrawable

The element to add.

Returns

Container

this Container object.

DrawOn(Page)

Draws this container and its child elements onto the page.

public float[] DrawOn(Page page)

Parameters

page Page

The Page to draw on.

Returns

float[]

An array containing the bottom-right position of the container.

Exceptions

Exception

Thrown if drawing fails.

GetRotationCenter()

Returns the center of this container, which it rotates around.

public float[] GetRotationCenter()

Returns

float[]

ScaleBy(float)

Sets a uniform scaling factor for both X and Y axes.

public Container ScaleBy(float factor)

Parameters

factor float

The scaling factor to apply.

Returns

Container

ScaleBy(float, float)

Sets non-uniform scaling factors for the X and Y axes.

public Container ScaleBy(float sx, float sy)

Parameters

sx float

The scaling factor for X.

sy float

The scaling factor for Y.

Returns

Container

SetBorderColor(int)

Sets the 0xRRGGBB color of the border around this container. Color.transparent leaves it unchanged.

public Container SetBorderColor(int borderColor)

Parameters

borderColor int

Returns

Container

SetBorderColor(float[])

Sets the color of the border around this container.

public Container SetBorderColor(float[] rgbColor)

Parameters

rgbColor float[]

the color as red, green and blue components from 0.0 to 1.0.

Returns

Container

this Container object.

SetLocation(float, float)

Sets the location of the container on the page.

public Container SetLocation(float x, float y)

Parameters

x float

The X coordinate.

y float

The Y coordinate.

Returns

Container

SetRotation(float)

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

public Container SetRotation(float degrees)

Parameters

degrees float

The rotation angle in degrees.

Returns

Container