# Container Class

> A container class represents a group of elements on a page in a PDF file.

- Product: Adobe PDF Library 21
- Language: Modern C++
- Version: 21.4.0
- HTML page: https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Container
- Version index: https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/llms.txt

```cpp
class Container : Element
```

**Namespace:** `datalogics_interface`

**Inherits from:** [`Element`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Element.md)

## Description

A container class represents a group of elements on a page in a PDF file.

In the PDF file, every container has a set of Marked Content tags, starting with Begin Marked Content (BMC or BDC) and ending with End Marked Content (EMC), so each container has a BMC/EMC or BDC/EMC pair of tags. These tags can be used to define the beginning and end of metadata around objects, providing information about the text and shapes within a PDF file. Containers can be nested within other containers.

**Referenced by:** [`Container`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Container.md)

**Uses types:** [`Clip`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Clip.md), [`Container`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Container.md), [`Content`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Content.md), [`Element`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Element.md), [`ElementCloneFlags`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/ElementCloneFlags.md), [`ElementType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/ElementType.md), [`Matrix`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/struct/Matrix.md), [`OptionalContentMembershipDict`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OptionalContentMembershipDict.md), [`PDFDict`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFDict.md), [`Rect`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/struct/Rect.md)

## Constructors

### Container

```cpp
datalogics_interface::Container::Container()
```

*constructor*

Create a new Container.

The new Container has no tag and is not associated with a dictionary.

### Container

```cpp
datalogics_interface::Container::Container(const std::string &mc_tag)
```

*constructor*

**Parameters**

- `mc_tag` (`const std::string &`)

Create a new Container.

The new Container has no tag and is not associated with a dictionary.

### Container

```cpp
datalogics_interface::Container::Container(const std::string &mc_tag, const PDFDict &property_list, bool is_inline)
```

*constructor*

**Parameters**

- `mc_tag` (`const std::string &`)
- `property_list` ([`const PDFDict &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFDict.md))
- `is_inline` (`bool`)

Create a new Container.

The new Container has no tag and is not associated with a dictionary.

### Container

```cpp
datalogics_interface::Container::Container(Container &&) noexcept
```

*constructor*

**Parameters**

- (unnamed) ([`Container &&`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Container.md))

### ~Container

```cpp
datalogics_interface::Container::~Container() override
```

*destructor*

## Methods

### clear_content

```cpp
void datalogics_interface::Container::clear_content()
```

**Returns:** `void`

Removes the content from this container.

### clear_optional_content_membership_dict

```cpp
void datalogics_interface::Container::clear_optional_content_membership_dict()
```

**Returns:** `void`

Removes the optional content membership dictionary from this container.

### clone

```cpp
std::unique_ptr< Container > datalogics_interface::Container::clone() const
```

**Returns:** [`std::unique_ptr< Container >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Container.md)

The copied container.

Makes a copy of the container.

Make a copy of an container to obtain a new container that has a distinct set of attributes.

### clone

```cpp
std::unique_ptr< Element > datalogics_interface::Element::clone(ElementCloneFlags flags) const
```

**Parameters**

- `flags` ([`ElementCloneFlags`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/ElementCloneFlags.md))

**Returns:** [`std::unique_ptr< Element >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Element.md)

The copied element.

Makes a copy of the element.

Make a copy of an element to obtain a new element that has a distinct set of attributes.

Note: TextRun objects may not be cloned.

### get_bounding_box

```cpp
Rect datalogics_interface::Element::get_bounding_box() const
```

**Returns:** [`Rect`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/struct/Rect.md)

The bounding box for this element. The coordinates of the bounding box are specified in user space coordinates, relative to the element's Content. Note that user space coordinates correspond to unrotated pages; any rotation specified in the page dictionary is not taken into account.

The bounding box for this element.

The bounding box is a rectangle that is guaranteed to encompass the element, but it is not guaranteed to be the smallest box that could contain the element. For example, if the element is a Path that contains an arc, the bounding box encompasses the bezier control points, and not just the curve itself.

### get_clip

```cpp
std::unique_ptr< Clip > datalogics_interface::Element::get_clip()
```

**Returns:** [`std::unique_ptr< Clip >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Clip.md)

The current Clip for this Element, or NULL if no clip is set.

Gets the current Clip for an Element.

### get_content

```cpp
std::unique_ptr< Content > datalogics_interface::Container::get_content() const
```

**Returns:** [`std::unique_ptr< Content >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Content.md)

Obtain the content of a container.

### get_element_type

```cpp
ElementType datalogics_interface::Element::get_element_type() const
```

**Returns:** [`ElementType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/ElementType.md)

Returns the runtime type of this element.

### get_marked_content_tag

```cpp
std::string datalogics_interface::Container::get_marked_content_tag() const
```

**Returns:** `std::string`

The container's Marked Content Tag.

### get_matrix

```cpp
Matrix datalogics_interface::Element::get_matrix() const
```

**Returns:** [`Matrix`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/struct/Matrix.md)

The current transformation matrix applied to this element.

The transformation matrix for the element.

### get_optional_content_membership_dict

```cpp
std::unique_ptr< OptionalContentMembershipDict > datalogics_interface::Container::get_optional_content_membership_dict() const
```

**Returns:** [`std::unique_ptr< OptionalContentMembershipDict >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OptionalContentMembershipDict.md)

the OptionalContentMembershipDict

The OptionalContentMembershipDict property for this Container.

Setting this property will attach the Container to an OptionalContentMembershipDict; it will then be associated with the OptionalContentGroups and be subject to the VisibilityPolicy and VisibilityExpression of that MembershipDict.

By setting this property to null, the Container is detached from any OptionalContentMembershipDict.

### get_pdf_dict

```cpp
PDFDict datalogics_interface::Container::get_pdf_dict() const
```

**Returns:** [`PDFDict`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFDict.md)

Retrieve the PDFObject representation of this object.

### operator=

```cpp
Container & datalogics_interface::Container::operator=(Container &&) noexcept
```

**Parameters**

- (unnamed) ([`Container &&`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Container.md))

**Returns:** [`Container &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Container.md)

### rotate

```cpp
void datalogics_interface::Element::rotate(double theta)
```

**Parameters**

- `theta` (`double`): The rotation angle in degrees.

**Returns:** `void`

Rotate an element by theta degrees counterclockwise using the matrix [ cos T sin T -sin T cos T 0 0 ].

### scale

```cpp
void datalogics_interface::Element::scale(double sx, double sy)
```

**Parameters**

- `sx` (`double`): The horizontal scale factor.
- `sy` (`double`): The vertical scale factor.

**Returns:** `void`

Scale an element by (sx,sy) units using the matrix [ sx 0 0 sy 0 0 ].

### set_clip

```cpp
void datalogics_interface::Element::set_clip(Clip &clip)
```

**Parameters**

- `clip` ([`Clip &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Clip.md)): The clip to set as the current clip for this element, or NULL to remove clipping.

**Returns:** `void`

Sets the current Clip for an Element.

### set_content

```cpp
void datalogics_interface::Container::set_content(const Content &content)
```

**Parameters**

- `content` ([`const Content &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Content.md)): The new Content of the container.

**Returns:** `void`

Set the content of a container.

### set_marked_content_tag

```cpp
void datalogics_interface::Container::set_marked_content_tag(const std::string &tag)
```

**Parameters**

- `tag` (`const std::string &`): the container's Marked Content Tag

**Returns:** `void`

The container's Marked Content Tag.

### set_matrix

```cpp
void datalogics_interface::Element::set_matrix(const Matrix &matrix)
```

**Parameters**

- `matrix` ([`const Matrix &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/struct/Matrix.md)): The transformation matrix for the element.

**Returns:** `void`

Set the transformation matrix for the element.

### set_optional_content_membership_dict

```cpp
void datalogics_interface::Container::set_optional_content_membership_dict(const OptionalContentMembershipDict &ocmd)
```

**Parameters**

- `ocmd` ([`const OptionalContentMembershipDict &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OptionalContentMembershipDict.md)): the OptionalContentMembershipDict

**Returns:** `void`

The OptionalContentMembershipDict property for this Container.

Setting this property will attach the Container to an OptionalContentMembershipDict; it will then be associated with the OptionalContentGroups and be subject to the VisibilityPolicy and VisibilityExpression of that MembershipDict.

By setting this property to null, the Container is detached from any OptionalContentMembershipDict.

### translate

```cpp
void datalogics_interface::Element::translate(double tx, double ty)
```

**Parameters**

- `tx` (`double`): The horizontal translation distance in user space units.
- `ty` (`double`): The vertical translation distance in user space units.

**Returns:** `void`

Translate an element by (tx,ty) units using the matrix [ 1 0 0 1 tx ty ].

### try_as

```cpp
T * datalogics_interface::Element::try_as()
```

**Parameters**

- (unnamed) (`typename T`)

**Returns:** `T *`

Attempt to downcast this element to a derived type. Returns a pointer to the derived type, or nullptr if the type doesn't match.

### try_as

```cpp
const T * datalogics_interface::Element::try_as() const
```

**Parameters**

- (unnamed) (`typename T`)

**Returns:** `const T *`

Const overload of try_as(). Returns a const pointer, or nullptr.
