HighlightAnnotation Class Documentation

class HighlightAnnotation : TextMarkupAnnotation

Namespace:datalogics_interface

Inherits from:
TextMarkupAnnotation

Detailed Description

Allows the user to highlight text appearing on a PDF page.

The annotated text is still readable on the PDF, but highlighted in yellow.

Constructor & Destructor Documentation

HighlightAnnotation

HighlightAnnotation(Page & page, const std::vector< Quad > & quads)

Parameters

page: Page &

The page to which the HighlightAnnotation is added.

quads: const std::vector< Quad > &

A list of quads to highlight. Each quad encompasses a word or group of contiguous words in the text underlying the annotation.

Create a new HighlightAnnotation at the end of a page's annotation array. To create a FreeTextAnnotation and place it elsewhere in the page's annotation array, use the version of the constructor that takes an array position.

HighlightAnnotation

HighlightAnnotation(Page & page, int add_after, const std::vector< Quad > & quads)

Parameters

page: Page &

The page to which the HighlightAnnotation is added.

add_after: int

A list of quads to highlight. Each quad encompasses a word or group of contiguous words in the text underlying the annotation.

Create a new HighlightAnnotation at the end of a page's annotation array. To create a FreeTextAnnotation and place it elsewhere in the page's annotation array, use the version of the constructor that takes an array position.

~HighlightAnnotation

~HighlightAnnotation()

Member Function Documentation

clear_interior_color

void clear_interior_color()

Returns:

void

Clear the interior color.

generate_appearance

std::unique_ptr< Form > generate_appearance()

Returns:

std::unique_ptr< Form >

A Form representing the visual appearance, or null if the appearance could not be generated.

Generate a new appearance stream with the current annotation properties.

The resulting Form can then be used to set the annotation's appearance, such as by calling SetNormalAppearance.

get_annotated_text

std::string get_annotated_text(bool split_lines)

Parameters

split_lines: bool

If true, text corresponding to each quadrilateral will be separated by CRLF characters. If false, text corresponding to each quadrilateral will be separated by spaces.

Returns:

std::string

The text marked by the annotation.

The text that is marked by the annotation. Marked text is defined as text which falls within one or more of the quadrilaterals specified by the annotation's QuadPoints entry. If the annotation marks partial words, only those portions of the word that are bounded within the QuadPoints array will be returned. If the annotation marks partial characters, the characters that fall partially within the annotation bounds may not be returned.

get_annotation_feature_level

double get_annotation_feature_level()

Returns:

double

The minimum PDF version level (e.g. 1.3, 1.4, or 1.5).

The minimum PDF version necessary to support the features used in this annotation.

get_color

Color get_color()

Returns:

Color

The annotation's color.

The color of the annotation.

get_contents

std::string get_contents()

Returns:

std::string

The annotation's text contents.

The text contents of the annotation.

The text to be displayed for the annotation or, if this type of annotation does not display text, an alternate description of the annotation's contents in human-readable form.

get_interior_color

std::unique_ptr< Color > get_interior_color()

Returns:

std::unique_ptr< Color >

The interior fill color, or null if no interior color is set.

The interior color with which to fill the annotation's rectangle or circle.

The color of the border itself can be retrieved from Annotation.Color.

get_normal_appearance

std::unique_ptr< Form > get_normal_appearance()

Returns:

std::unique_ptr< Form >

A Form representing the annotation's normal appearance, or null if no normal appearance has been set.

The normal appearance of the annotation, represented as a Form XObject.

get_opacity

double get_opacity()

Returns:

double

The opacity value for this annotation.

The constant opacity value used in painting a Markup annotation.

Opacity is a range from 0.0 (fully transparent) to 1.0 (fully opaque).

get_rect

Rect get_rect()

Returns:

Rect

The annotation's bounding rectangle in user space coordinates.

The size and location of the annotation on its page.

get_subtype

std::string get_subtype()

Returns:

std::string

The subtype string (e.g. "Circle", "Square", "Line").

The annotation's subtype.

get_title

std::string get_title()

Returns:

std::string

The title string.

The title of the annotation.

has_rich_text_data

bool has_rich_text_data()

Returns:

bool

true if the annotation contains Rich Text String content.

Checks the annotation for Rich Text String content (PDFReference 1.7 Section 8.6.2). Annotations that contain Rich Text String content and do not have a normal appearance set will not be visible when rendering the page.

operator==

bool operator==(const Annotation & other)

Parameters

other: const Annotation &

The annotation to compare with this annotation.

Returns:

bool

true if the two annotations are equal.

Test annotations for equality (if they are the same annotation).

set_annotation_feature_level

void set_annotation_feature_level(double level)

Parameters

level: double

The target PDF version level. Features requiring a higher version will be removed.

Returns:

void

Removes features not supported in the supplied version number.

set_color

void set_color(const Color & color)

Parameters

color: const Color &

The new color to set.

Returns:

void

The color of the annotation.

set_contents

void set_contents(const std::string & contents)

Parameters

contents: const std::string &

The new text contents.

Returns:

void

The text contents of the annotation.

The text to be displayed for the annotation or, if this type of annotation does not display text, an alternate description of the annotation's contents in human-readable form.

set_flags

void set_flags(AnnotationFlags flags)

Parameters

flags: AnnotationFlags

The new annotation flags to set.

Returns:

void

The flags for the annotation.

set_interior_color

void set_interior_color(const Color & color)

Parameters

color: const Color &

The new interior fill color. Pass null to remove the interior color.

Returns:

void

The interior color with which to fill the annotation's rectangle or circle.

Only RGB colors are allowed.

The color of the border itself can be retrieved from Annotation.Color.

set_normal_appearance

void set_normal_appearance(Form & form)

Parameters

form: Form &

The Form to use as the annotation's normal appearance.

Returns:

void

The normal appearance of the annotation, represented as a Form XObject.

set_opacity

void set_opacity(double opacity)

Parameters

opacity: double

The new opacity value to set.

Returns:

void

The constant opacity value used in painting a Markup annotation.

Opacity is a range from 0.0 (fully transparent) to 1.0 (fully opaque).

set_quads

void set_quads(const std::vector< Quad > & quads)

Parameters

quads: const std::vector< Quad > &

a list of quads to mark. Each quad encompasses a word or group of contiguous words in the text underlying the annotation

Returns:

void

A list of quads to mark. Each quad encompasses a word or group of contiguous words in the text underlying the annotation.

set_rect

void set_rect(const Rect & rect)

Parameters

rect: const Rect &

The new bounding rectangle in user space coordinates.

Returns:

void

The size and location of the annotation on its page.

set_title

void set_title(const std::string & title)

Parameters

title: const std::string &

The new title string.

Returns:

void

The title of the annotation.

to_string

std::string to_string()

Returns:

std::string

A string describing this annotation, including its type and rectangle.

Returns a string representation of this annotation.

try_as

T * try_as(typename T )

Parameters

: typename T

Returns:

T *

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

try_as

const T * try_as(typename T )

Parameters

: typename T

Returns:

const T *

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