Content Class Documentation
classContentNamespace:datalogics_interface
Detailed Description
A content object represents a collection of elements that make up a page in a PDF file. A content object is more convenient to use than directly parsing or working with a page content stream. This is because a page can include a large collection of individual stream objects. Working with a content object, you can avoid focusing on this level of detail. The content converts individual stream items to a structured form, making it unnecessary to parse the individual syntax for each one. A content object can be associated with a large amount of unmanaged memory in APDFL and should be deleted when the object is no longer in use.
The index associated with Content is 0-based, so 0 is the first element.
Uses types
Constructor & Destructor Documentation
Content
Content()Create content.
Content
Content(Content &&)Parameters
Content
Content(Element &first_elem)Parameters
first_elem: Element &
Create content.
~Content
~Content()Member Function Documentation
add_element
voidadd_element(const Element &elem)Parameters
elem: const Element &- The Element which is to be added to the end of the existing Content object.
Returns:
voidAdds an existing Element at the end of the content object.
add_element
voidadd_element(const Element &elem, intadd_after_index)Parameters
elem: const Element &- The Element which is to be added to the end of the existing Content object.
add_after_index: int
Returns:
voidAdds an existing Element at the end of the content object.
add_page
voidadd_page(intinsert_after_index, Document &container_doc, Page &src_page, std::optional< Matrix >dst_matrix, std::optional< std::vector< std::string > >annot_types, AddPageFlagsflags, std::optional< Rect >bbox)Parameters
insert_after_index: intThe index indicates the location after which the specified element is to be added. The index should be BeforeFirst to add to the beginning of the display list.
container_doc: Document &The Document in which the page is contained.
src_page: Page &The page that will be inserted at insertAfterIndex in theContent.
dst_matrix: std::optional< Matrix >(May be NULL) The matrix applied to the default matrix of the Page that is inserted into the Document.
annot_types: std::optional< std::vector< std::string > >If the page contains annotations, the annotTypes list is used to determine which annotation types are pumped into the page contents of the CosDoc.
flags: AddPageFlags(May be 0) AllAnnotations specifies all annotation types. If this is not set, then the annotTypes list will be consulted.
bbox: std::optional< Rect >(May be NULL) specifies the destination BBox for the page being inserted. If it is NULL, the new page's media box is used.
Returns:
voidAdds the specfied Page to the Content as a Form. It adds a reference to the Xobject form at the indicated index in the Content; the index may be less than 0, which indicates the object is to be appended to the content.
flatten_optional_content
boolflatten_optional_content(OptionalContentContext &occ)Parameters
occ: OptionalContentContext &The optional content context in which content is checked for visibility.
Returns:
true if the content was successfully flattened, false otherwise.Flattens optional content within this Content object.
Removes elements that are not visible in the given optional content context and removes optional content information from any visible elements.
The optional content information formerly associated with this Content object will NOT be deleted from the document, as it is possible that content elsewhere in the document may be using the information.
get_bounding_box
Rectget_bounding_box()Returns:
A Rect representing the bounding box of all elements in this Content.The bounding box for this content.
The bounding box is a rectangle that is at least large enough to contain the bounding boxes for all the elements in the Content.
get_default_color_space
std::unique_ptr< ColorSpace >get_default_color_space(const std::string &name)Parameters
name: const std::string &The name of the color space to get. It must be one of DefaultRGB, DefaultCMYK, or DefaultGray.
Returns:
The color space used as the default. May return null if no default is set.Get a default color space from a Content object.
See Section 4.5.4 in the PDF Reference for more information about default color spaces.
get_element
std::unique_ptr< Element >get_element(intindex)Parameters
index: intThe zero-based index of the element to retrieve.
Returns:
The Element at the specified index.Get the element specified by index.
get_num_elements
intget_num_elements()Returns:
The number of elements contained in this Content.The number of elements in the Content object.
operator=
Content &operator=(Content &&)Parameters
Returns:
Content &remove_element
voidremove_element(intindex)Parameters
index: int- The position at which to remove the Element
Returns:
voidRemoves the Element at the specified index.
set_default_color_space
voidset_default_color_space(const std::string &name, const ColorSpace &color_space)Parameters
name: const std::string &The name of the color space to set. It must be one of DefaultRGB, DefaultCMYK, or DefaultGray.
color_space: const ColorSpace &The color space to set. It may not be a Lab, Indexed or Pattern color space.
Returns:
voidSet a default color space from a Content object.
See Section 4.5.4 in the PDF Reference for more information about default color spaces.
to_string
std::stringto_string()Returns:
A string describing this Content object.The string includes the number of elements in the Content.