Represents fragment of Pdf text. More...

Inherits Aspose::Pdf::BaseParagraph.

Inherited by Aspose::Pdf::Heading.

Public Member Functions

System::String get_Text ()
 Gets System::String text object that the TextFragment object represents. More...
 
void set_Text (System::String value)
 Sets System::String text object that the TextFragment object represents. More...
 
virtual Aspose::Pdf::VerticalAlignment get_VerticalAlignment ()
 Gets a vertical alignment of text fragment. More...
 
virtual void set_VerticalAlignment (Aspose::Pdf::VerticalAlignment value)
 Sets a vertical alignment of text fragment. More...
 
virtual Aspose::Pdf::HorizontalAlignment get_HorizontalAlignment ()
 Gets a horizontal alignment of text fragment. More...
 
virtual void set_HorizontalAlignment (Aspose::Pdf::HorizontalAlignment value)
 Sets a horizontal alignment of text fragment. More...
 
virtual void set_Hyperlink (System::SharedPtr< Aspose::Pdf::Hyperlink > value)
 Sets the fragment hyperlink More...
 
System::SharedPtr< TextFragmentStateget_TextState ()
 Gets text state for the text that TextFragment object represents. More...
 
System::SharedPtr< TextSegmentCollectionget_Segments ()
 Gets text segments for current TextFragment. More...
 
void set_Segments (System::SharedPtr< TextSegmentCollection > value)
 Gets text segments for current TextFragment. More...
 
System::SharedPtr< Aspose::Pdf::Text::Positionget_Position ()
 Gets text position for text, represented with TextFragment object. More...
 
void set_Position (System::SharedPtr< Aspose::Pdf::Text::Position > value)
 Sets text position for text, represented with TextFragment object. More...
 
System::SharedPtr< Aspose::Pdf::Text::Positionget_BaselinePosition ()
 Gets text position for text, represented with TextFragment object. The YIndent of the Position structure represents baseline coordinate of the text fragment. More...
 
void set_BaselinePosition (System::SharedPtr< Aspose::Pdf::Text::Position > value)
 Gets text position for text, represented with TextFragment object. The YIndent of the Position structure represents baseline coordinate of the text fragment. More...
 
System::SharedPtr< Aspose::Pdf::Rectangleget_Rectangle ()
 Gets rectangle of the TextFragment More...
 
System::SharedPtr< Aspose::Pdf::Pageget_Page ()
 Gets page that contains the TextFragment More...
 
System::SharedPtr< XFormget_Form ()
 Gets form object that contains the TextFragment More...
 
int32_t get_WrapLinesCount ()
 Gets wrap lines count for this paragraph(for pdf generation only) More...
 
void set_WrapLinesCount (int32_t value)
 Sets wrap lines count for this paragraph(for pdf generation only) More...
 
System::SharedPtr< Noteget_EndNote ()
 Gets the paragraph end note.(for pdf generation only) More...
 
void set_EndNote (System::SharedPtr< Note > value)
 Sets the paragraph end note.(for pdf generation only) More...
 
System::SharedPtr< Noteget_FootNote ()
 Gets the paragraph foot note.(for pdf generation only) More...
 
void set_FootNote (System::SharedPtr< Note > value)
 Sets the paragraph foot note.(for pdf generation only) More...
 
 TextFragment ()
 Initializes new instance of the TextFragment object. More...
 
 TextFragment (System::SharedPtr< TabStops > tabStops)
 Initializes new instance of the TextFragment object with predefined TabStops positions. More...
 
 TextFragment (System::String text)
 Creates TextFragment object with single TextSegment object inside. Specifies text string inside the segment. More...
 
 TextFragment (System::String text, System::SharedPtr< TabStops > tabStops)
 Creates TextFragment object with single TextSegment object inside and predefined TabStops positions. More...
 
System::SharedPtr< TextSegmentCollectionIsolateTextSegments (int32_t startIndex, int32_t length)
 Gets TextSegment(s) representing specified part of the TextFragment text. More...
 
virtual System::SharedPtr< System::ObjectClone ()
 Clone the fragment. More...
 
virtual System::SharedPtr< System::ObjectCloneWithSegments ()
 Clone the fragment with all segments. More...
 
- Public Member Functions inherited from Aspose::Pdf::BaseParagraph
System::SharedPtr< MarginInfoget_Margin ()
 Gets a outer margin for paragraph (for pdf generation) More...
 
void set_Margin (System::SharedPtr< MarginInfo > value)
 Sets a outer margin for paragraph (for pdf generation) More...
 
bool get_IsFirstParagraphInColumn ()
 Gets a bool value that indicates whether this paragraph will be at next column. Default is false.(for pdf generation) More...
 
void set_IsFirstParagraphInColumn (bool value)
 Sets a bool value that indicates whether this paragraph will be at next column. Default is false.(for pdf generation) More...
 
bool get_IsKeptWithNext ()
 Gets a bool value that indicates whether current paragraph remains in the same page along with next paragraph. Default is false.(for pdf generation) More...
 
void set_IsKeptWithNext (bool value)
 Sets a bool value that indicates whether current paragraph remains in the same page along with next paragraph. Default is false.(for pdf generation) More...
 
bool get_IsInNewPage ()
 Gets a bool value that force this paragraph generates at new page. Default is false.(for pdf generation) More...
 
void set_IsInNewPage (bool value)
 Sets a bool value that force this paragraph generates at new page. Default is false.(for pdf generation) More...
 
bool get_IsInLineParagraph ()
 Gets a paragraph is inline. Default is false.(for pdf generation) More...
 
void set_IsInLineParagraph (bool value)
 Sets a paragraph is inline. Default is false.(for pdf generation) More...
 
virtual System::SharedPtr< Aspose::Pdf::Hyperlinkget_Hyperlink ()
 Gets the fragment hyperlink(for pdf generator). More...
 
int32_t get_ZIndex ()
 Gets a int value that indicates the Z-order of the graph. A graph with larger ZIndex will be placed over the graph with smaller ZIndex. ZIndex can be negative. Graph with negative ZIndex will be placed behind the text in the page. More...
 
void set_ZIndex (int32_t value)
 Sets a int value that indicates the Z-order of the graph. A graph with larger ZIndex will be placed over the graph with smaller ZIndex. ZIndex can be negative. Graph with negative ZIndex will be placed behind the text in the page. More...
 
 BaseParagraph ()
 
- Public Member Functions inherited from System::Object
ASPOSECPP_SHARED_API Object ()
 Creates object. Initializes all internal data structures. More...
 
virtual ASPOSECPP_SHARED_API ~Object ()
 Destroys object. Frees all internal data structures. More...
 
ASPOSECPP_SHARED_API Object (Object const &x)
 Copy constructor. Doesn't copy anything, really, just initializes new object and enables copy constructing subclasses. More...
 
Objectoperator= (Object const &x)
 Assignment operator. Doesn't copy anything, really, just initializes new object and enables copy constructing subclasses. More...
 
ObjectSharedRefAdded ()
 Increments shared reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
int SharedRefRemovedSafe ()
 Decrements and returns shared reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
int RemovedSharedRefs (int count)
 Decreases shared reference count by specified value. More...
 
Detail::SmartPtrCounter * WeakRefAdded ()
 Increments weak reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
void WeakRefRemoved ()
 Decrements weak reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
Detail::SmartPtrCounter * GetCounter ()
 Gets reference counter data structure associated with the object. More...
 
int SharedCount () const
 Gets current value of shared refernce counter. More...
 
ASPOSECPP_SHARED_API void Lock ()
 Implements C# lock() statement locking. Call directly or use LockContext sentry object. More...
 
ASPOSECPP_SHARED_API void Unlock ()
 Implements C# lock() statement unlocking. Call directly or use LockContext sentry object. More...
 
virtual ASPOSECPP_SHARED_API bool Equals (ptr obj)
 Compares objects using C# Object.Equals semantics. More...
 
virtual ASPOSECPP_SHARED_API int GetHashCode () const
 Analog of C# Object.GetHashCode() method. Enables hashing of custom objects. More...
 
virtual ASPOSECPP_SHARED_API String ToString () ASPOSE_CONST
 Analog of C# Object.ToString() method. Enables converting custom objects to string. More...
 
virtual ASPOSECPP_SHARED_API ptr MemberwiseClone () const
 Analog of C# Object.MemberwiseClone() method. Enables cloning custom types. More...
 
virtual ASPOSECPP_SHARED_API const TypeInfoGetType () const
 Gets actual type of object. Analog of C# System.Object.GetType() call. More...
 
virtual ASPOSECPP_SHARED_API bool Is (const TypeInfo &targetType) const
 Check if object represents an instance of type described by targetType. Analog of C# 'is' operator. More...
 
virtual ASPOSECPP_SHARED_API void SetTemplateWeakPtr (unsigned int argument)
 Set n'th template argument a weak pointer (rather than shared). Allows switching pointers in containers to weak mode. More...
 
template<>
bool Equals (float const &objA, float const &objB)
 
template<>
bool Equals (double const &objA, double const &objB)
 
template<>
bool ReferenceEquals (String const &str, std::nullptr_t)
 
template<>
bool ReferenceEquals (String const &str1, String const &str2)
 

Protected Member Functions

Aspose::Pdf::Text::TextState::AttachState get_AttachedState ()
 
void set_AttachedState (Aspose::Pdf::Text::TextState::AttachState value)
 
System::SharedPtr< TextReplaceOptionsget_ReplaceOptions ()
 
void set_ReplaceOptions (System::SharedPtr< TextReplaceOptions > value)
 
System::String get_McName ()
 
int32_t get_McId ()
 
System::SharedPtr< Aspose::Pdf::Engine::CommonData::Text::Segmenting::SegmentsGroupState > get_SegmentsGroupState ()
 
void set_SegmentsGroupState (System::SharedPtr< Aspose::Pdf::Engine::CommonData::Text::Segmenting::SegmentsGroupState > value)
 
void set_TextState (System::SharedPtr< TextFragmentState > value)
 Sets text state for the text that TextFragment object represents. More...
 
System::SharedPtr< TextFragmentCollectionget_Fragments ()
 Gets collection that contains current fragment More...
 
void set_Fragments (System::SharedPtr< TextFragmentCollection > value)
 Sets collection that contains current fragment More...
 
void set_Rectangle (System::SharedPtr< Aspose::Pdf::Rectangle > value)
 Gets rectangle of the TextFragment More...
 
void set_Page (System::SharedPtr< Aspose::Pdf::Page > value)
 Gets page that contains the TextFragment More...
 
System::SharedPtr< Aspose::Pdf::Engine::CommonData::Text::Segmenting::TextSegmenter > get_Segmenter ()
 Gets TextSegmenter that was used for creation segments of this fragment. More...
 
bool get_IsPositionChanged ()
 Indicates whether position of the fragment is changed or default More...
 
void SetEncodedTextProperties (System::SharedPtr< Font > font, System::String text, System::ArrayPtr< int32_t > indices)
 Sets font and indices inside the font More...
 
void Attach (System::SharedPtr< Aspose::Pdf::Engine::CommonData::Text::Segmenting::TextSegmenter > segmenter)
 Attaches to the segmenter More...
 
void IsolateToSingleSegment ()
 Isolates segments to single segment for simpler editing. More...
 
void IsolateToText ()
 Isolates segments to segment that represent the text only. i.e. we Trim from beginning and end More...
 
System::SharedPtr< Aspose::Pdf::RectangleComputeUnderlineRectangle ()
 
System::ArrayPtr< System::SharedPtr< Aspose::Pdf::Engine::CommonData::Text::Segmenting::PhysicalTextSegment > > GetAttachedPhysicalSegmentsArray (int32_t &firstSegmentIndex, int32_t &lastSegmentIndex)
 
void ResetTabstops ()
 
bool IsMultiline ()
 Indicates whether the fragment contains segments on different "text lines" More...
 
 TextFragment (System::String text, System::SharedPtr< TextSegmentCollection > segments)
 
 TextFragment (System::SharedPtr< Aspose::Pdf::Engine::CommonData::Text::Segmenting::TextSegmenter > segmenter, System::String text, System::SharedPtr< TextSegmentCollection > segments)
 
void SyncVerticalAlignment (Aspose::Pdf::VerticalAlignment verticalAlignment)
 
void SyncHorizontalAlignment (Aspose::Pdf::HorizontalAlignment horizontalAlignment1)
 
void LightWeightTextSetter (System::String inText)
 Set text with no adjustment. More...
 
void LightWeightTextSetterWithNoTextShift (System::String inText)
 Set text with no adjustment. More...
 
System::SharedPtr< System::Collections::Generic::List< System::SharedPtr< Aspose::Pdf::Engine::CommonData::Text::Segmenting::PhysicalTextSegment > > > GetLineSegments (double x_indent, double y_indent, double angle)
 
void SetMarkedContentProperties (System::String name, int32_t id)
 
void Assign (System::SharedPtr< TextFragment > fragment)
 
void AssignWithSegments (System::SharedPtr< TextFragment > fragment)
 
virtual void Serialize (System::SharedPtr< System::Xml::XmlTextWriter > writer)
 
virtual void Deserialize (System::SharedPtr< System::Xml::XmlReader > reader)
 
- Protected Member Functions inherited from Aspose::Pdf::BaseParagraph
System::String get_Id ()
 Gets a paragraph id. More...
 
void set_Id (System::String value)
 Sets a paragraph id. More...
 
System::SharedPtr< Annotations::LinkAnnotationget_ReferencedFrom ()
 Gets the fragment hyperlink(for pdf generator internal use). More...
 
void set_ReferencedFrom (System::SharedPtr< Annotations::LinkAnnotation > value)
 Sets the fragment hyperlink(for pdf generator internal use). More...
 
void ChangePosition (double &curX, double &curY, double newX, double newY, bool isNextParagraphInline)
 
void ProcessHyperlink (System::SharedPtr< Page > page, System::SharedPtr< Rectangle > rect)
 

Static Protected Member Functions

static System::SharedPtr< Aspose::Pdf::RectangleGetGroupRectangle (System::SharedPtr< TextSegmentCollection > segments, int32_t firstSegmentBeginIndex, int32_t lastSegmentEndIndex, bool measureLastTechnicalSpacings)
 
- Static Protected Member Functions inherited from Aspose::Pdf::BaseParagraph
static bool get_IsZIndexSet ()
 Gets the fragment hyperlink(for pdf generator performance internal use). More...
 
static void set_IsZIndexSet (bool value)
 Sets the fragment hyperlink(for pdf generator performance internal use). More...
 

Protected Attributes

System::EventHandler OnRectChanged
 

Additional Inherited Members

- Public Types inherited from System::Object
typedef SmartPtr< Objectptr
 Alias for smart pointer type. More...
 
typedef System::Details::SharedMembersType shared_members_type
 structure to keep list of shared pointers contained in object. More...
 
- Static Public Member Functions inherited from System::Object
static bool ReferenceEquals (ptr const &objA, ptr const &objB)
 Compares objects by reference. More...
 
template<typename T >
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, T const &objB)
 Compares objects by reference. More...
 
template<typename T >
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, std::nullptr_t)
 Reference-compares value type object with nullptr. More...
 
template<typename T1 , typename T2 >
static std::enable_if< IsSmartPtr< T1 >::value &&IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 Compares reference type objects in C# style. More...
 
template<typename T1 , typename T2 >
static std::enable_if<!IsSmartPtr< T1 >::value &&!IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 Compares value type objects in C# style. More...
 
static const TypeInfoType ()
 Impleemnts C# typeof(System.Object) construct. More...
 

Detailed Description

Represents fragment of Pdf text.

In a few words, TextFragment object contains list of TextSegment objects.

In details: Text of pdf document in Aspose::Pdf is represented by two basic objects: TextFragment and TextSegment

The differences between them is mostly context-dependent.

Let's consider following scenario. User searches text "hello world" to operate with it, change it's properties, look etc.

Document doc = new Document(docFile);
TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world");
doc.Pages[1].Accept(absorber);

Phisycally pdf text's representation is very complex. The text "hello world" may consist of several phisycally independent text segments.

The Aspose.Pdf text model basically establishes that TextFragment object provides single logic operation set over physical TextSegment objects set that represent user's query.

In text search scenario, TextFragment is logical "hello world" text representation, and TextSegment object collection represents all physical segments that construct "hello world" text object.

So, TextFragment is close to logical text representation. And TextSegment is close to physical text representation.

Obviously each TextSegment object may have it's own font, coloring, positioning properties.

TextFragment provides simple way to change text with it's properties: set font, set font size, set font color etc. Meanwhile TextSegment objects are accessible and users are able to operate with TextSegment objects independently.

Note that changing TextFragment properties may change inner Segments collection because TextFragment is an aggregate object and it may rearrange internal segments or merge them into single segment. If your requirement is to leave the Segments collection unchanged, please change inner segments individually.

The example demonstrates how to find text on the first PDF document page and replace the text and it's font.

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Find font that will be used to change document text font
Aspose.Pdf.Txt.Font font = FontRepository.FindFont("Arial");
// Create TextFragmentAbsorber object to find all "hello world" text occurrences
TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world");
// Accept the absorber for first page
doc.Pages[1].Accept(absorber);
// Change text and font of the first text occurrence
absorber.TextFragments[1].Text = "hi world";
absorber.TextFragments[1].TextState.Font = font;
// Save document
doc.Save(@"D:\Tests\output.pdf");

Constructor & Destructor Documentation

◆ TextFragment() [1/6]

Aspose::Pdf::Text::TextFragment::TextFragment ( )

Initializes new instance of the TextFragment object.

◆ TextFragment() [2/6]

Aspose::Pdf::Text::TextFragment::TextFragment ( System::SharedPtr< TabStops tabStops)

Initializes new instance of the TextFragment object with predefined TabStops positions.

Parameters
tabStopsTabulation positions

◆ TextFragment() [3/6]

Aspose::Pdf::Text::TextFragment::TextFragment ( System::String  text)

Creates TextFragment object with single TextSegment object inside. Specifies text string inside the segment.

Parameters
textText fragment's text.

◆ TextFragment() [4/6]

Aspose::Pdf::Text::TextFragment::TextFragment ( System::String  text,
System::SharedPtr< TabStops tabStops 
)

Creates TextFragment object with single TextSegment object inside and predefined TabStops positions.

Parameters
textText fragment's text.
tabStopsTabulation positions

◆ TextFragment() [5/6]

Aspose::Pdf::Text::TextFragment::TextFragment ( System::String  text,
System::SharedPtr< TextSegmentCollection segments 
)
protected

◆ TextFragment() [6/6]

Aspose::Pdf::Text::TextFragment::TextFragment ( System::SharedPtr< Aspose::Pdf::Engine::CommonData::Text::Segmenting::TextSegmenter >  segmenter,
System::String  text,
System::SharedPtr< TextSegmentCollection segments 
)
protected

Member Function Documentation

◆ Assign()

void Aspose::Pdf::Text::TextFragment::Assign ( System::SharedPtr< TextFragment fragment)
protected

◆ AssignWithSegments()

void Aspose::Pdf::Text::TextFragment::AssignWithSegments ( System::SharedPtr< TextFragment fragment)
protected

◆ Attach()

void Aspose::Pdf::Text::TextFragment::Attach ( System::SharedPtr< Aspose::Pdf::Engine::CommonData::Text::Segmenting::TextSegmenter >  segmenter)
protected

Attaches to the segmenter

Parameters
segmenter

◆ Clone()

virtual System::SharedPtr<System::Object> Aspose::Pdf::Text::TextFragment::Clone ( )
virtual

Clone the fragment.

Returns
The cloned object

Reimplemented from Aspose::Pdf::BaseParagraph.

Reimplemented in Aspose::Pdf::Heading.

◆ CloneWithSegments()

virtual System::SharedPtr<System::Object> Aspose::Pdf::Text::TextFragment::CloneWithSegments ( )
virtual

Clone the fragment with all segments.

Returns
The cloned object

Reimplemented in Aspose::Pdf::Heading.

◆ ComputeUnderlineRectangle()

System::SharedPtr<Aspose::Pdf::Rectangle> Aspose::Pdf::Text::TextFragment::ComputeUnderlineRectangle ( )
protected

◆ Deserialize()

virtual void Aspose::Pdf::Text::TextFragment::Deserialize ( System::SharedPtr< System::Xml::XmlReader reader)
protectedvirtual

Reimplemented from Aspose::Pdf::BaseParagraph.

Reimplemented in Aspose::Pdf::Heading.

◆ get_AttachedState()

Aspose::Pdf::Text::TextState::AttachState Aspose::Pdf::Text::TextFragment::get_AttachedState ( )
protected

◆ get_BaselinePosition()

System::SharedPtr<Aspose::Pdf::Text::Position> Aspose::Pdf::Text::TextFragment::get_BaselinePosition ( )

Gets text position for text, represented with TextFragment object. The YIndent of the Position structure represents baseline coordinate of the text fragment.

◆ get_EndNote()

System::SharedPtr<Note> Aspose::Pdf::Text::TextFragment::get_EndNote ( )

Gets the paragraph end note.(for pdf generation only)

◆ get_FootNote()

System::SharedPtr<Note> Aspose::Pdf::Text::TextFragment::get_FootNote ( )

Gets the paragraph foot note.(for pdf generation only)

◆ get_Form()

System::SharedPtr<XForm> Aspose::Pdf::Text::TextFragment::get_Form ( )

Gets form object that contains the TextFragment

The value can be null in case the TextFragment object doesn't belong to a form.

◆ get_Fragments()

System::SharedPtr<TextFragmentCollection> Aspose::Pdf::Text::TextFragment::get_Fragments ( )
protected

Gets collection that contains current fragment

◆ get_HorizontalAlignment()

virtual Aspose::Pdf::HorizontalAlignment Aspose::Pdf::Text::TextFragment::get_HorizontalAlignment ( )
virtual

Gets a horizontal alignment of text fragment.

Reimplemented from Aspose::Pdf::BaseParagraph.

◆ get_IsPositionChanged()

bool Aspose::Pdf::Text::TextFragment::get_IsPositionChanged ( )
protected

Indicates whether position of the fragment is changed or default

◆ get_McId()

int32_t Aspose::Pdf::Text::TextFragment::get_McId ( )
protected

◆ get_McName()

System::String Aspose::Pdf::Text::TextFragment::get_McName ( )
protected

◆ get_Page()

System::SharedPtr<Aspose::Pdf::Page> Aspose::Pdf::Text::TextFragment::get_Page ( )

Gets page that contains the TextFragment

The value can be null in case the TextFragment object doesn't belong to any page.

◆ get_Position()

System::SharedPtr<Aspose::Pdf::Text::Position> Aspose::Pdf::Text::TextFragment::get_Position ( )

Gets text position for text, represented with TextFragment object.

The example demonstrates how to view placement of a text, represented by TextFragment object.

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object to find all "hello world" text occurrences
TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world");
// Accept the absorber for first page
doc.Pages[1].Accept(absorber);
// View text and placement info of first text occurrence
TextFragment firstOccurrence = absorber.TextFragments[1];
Console.Out.WriteLine(string.Format("fragment text: {0}", firstOccurrence.Text));
Console.Out.WriteLine(string.Format("fragment X indent: {0}", firstOccurrence.Position.XIndent));
Console.Out.WriteLine(string.Format("fragment Y indent: {0}", firstOccurrence.Position.YIndent));
See also
TextFragmentAbsorber, Document, TextSegment

◆ get_Rectangle()

System::SharedPtr<Aspose::Pdf::Rectangle> Aspose::Pdf::Text::TextFragment::get_Rectangle ( )

Gets rectangle of the TextFragment

◆ get_ReplaceOptions()

System::SharedPtr<TextReplaceOptions> Aspose::Pdf::Text::TextFragment::get_ReplaceOptions ( )
protected

◆ get_Segmenter()

System::SharedPtr<Aspose::Pdf::Engine::CommonData::Text::Segmenting::TextSegmenter> Aspose::Pdf::Text::TextFragment::get_Segmenter ( )
protected

Gets TextSegmenter that was used for creation segments of this fragment.

◆ get_Segments()

System::SharedPtr<TextSegmentCollection> Aspose::Pdf::Text::TextFragment::get_Segments ( )

Gets text segments for current TextFragment.

In a few words, TextSegment objects are children of TextFragment object. Advanced users may access segments directly to perform more complex text edit scenarios. For details, please look at TextFragment object description.

The example demonstrates how to navigate all TextSegment objects inside TextFragment.

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object to find all "hello world" text occurrences
TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world");
// Accept the absorber for first page
doc.Pages[1].Accept(absorber);
// Navigate all text segments and out their text and placement info
foreach (TextSegment segment in absorber.TextFragments[1].Segments)
{
Console.Out.WriteLine(string.Format("segment text: {0}", segment.Text));
Console.Out.WriteLine(string.Format("segment X indent: {0}", segment.Position.XIndent));
Console.Out.WriteLine(string.Format("segment Y indent: {0}", segment.Position.YIndent));
}
See also
TextFragmentAbsorber, Document, TextSegment

◆ get_SegmentsGroupState()

System::SharedPtr<Aspose::Pdf::Engine::CommonData::Text::Segmenting::SegmentsGroupState> Aspose::Pdf::Text::TextFragment::get_SegmentsGroupState ( )
protected

◆ get_Text()

System::String Aspose::Pdf::Text::TextFragment::get_Text ( )

Gets System::String text object that the TextFragment object represents.

The example demonstrates how to search a text and replace first occurrence represented with TextFragment object .

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object to find all "hello world" text occurrences
TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world");
// Accept the absorber for first page
doc.Pages[1].Accept(absorber);
// Change font of the first text occurrence
absorber.TextFragments[1].Text = "hi world";
// Save document
doc.Save(@"D:\Tests\output.pdf");
See also
TextFragmentAbsorber, Document

◆ get_TextState()

System::SharedPtr<TextFragmentState> Aspose::Pdf::Text::TextFragment::get_TextState ( )

Gets text state for the text that TextFragment object represents.

Provides a way to change following properties of the text: Font FontSize FontStyle ForegroundColor BackgroundColor

The example demonstrates how to change text color and font size of the text with TextState object.

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object to find all "hello world" text occurrences
TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world");
// Accept the absorber for first page
doc.Pages[1].Accept(absorber);
// Change foreground color of the first text occurrence
absorber.TextFragments[1].TextState.ForegroundColor = Color.FromRgb(System.Drawing.Color.Red);
// Change font size of the first text occurrence
absorber.TextFragments[1].TextState.FontSize = 15;
// Save document
doc.Save(@"D:\Tests\output.pdf");
See also
TextFragmentAbsorber, Document

◆ get_VerticalAlignment()

virtual Aspose::Pdf::VerticalAlignment Aspose::Pdf::Text::TextFragment::get_VerticalAlignment ( )
virtual

Gets a vertical alignment of text fragment.

Reimplemented from Aspose::Pdf::BaseParagraph.

◆ get_WrapLinesCount()

int32_t Aspose::Pdf::Text::TextFragment::get_WrapLinesCount ( )

Gets wrap lines count for this paragraph(for pdf generation only)

◆ GetAttachedPhysicalSegmentsArray()

System::ArrayPtr<System::SharedPtr<Aspose::Pdf::Engine::CommonData::Text::Segmenting::PhysicalTextSegment> > Aspose::Pdf::Text::TextFragment::GetAttachedPhysicalSegmentsArray ( int32_t &  firstSegmentIndex,
int32_t &  lastSegmentIndex 
)
protected

◆ GetGroupRectangle()

static System::SharedPtr<Aspose::Pdf::Rectangle> Aspose::Pdf::Text::TextFragment::GetGroupRectangle ( System::SharedPtr< TextSegmentCollection segments,
int32_t  firstSegmentBeginIndex,
int32_t  lastSegmentEndIndex,
bool  measureLastTechnicalSpacings 
)
staticprotected

◆ GetLineSegments()

System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<Aspose::Pdf::Engine::CommonData::Text::Segmenting::PhysicalTextSegment> > > Aspose::Pdf::Text::TextFragment::GetLineSegments ( double  x_indent,
double  y_indent,
double  angle 
)
protected

◆ IsMultiline()

bool Aspose::Pdf::Text::TextFragment::IsMultiline ( )
protected

Indicates whether the fragment contains segments on different "text lines"

<remark> Multiline text fragments may appeared for example as a result of hyphenation during text replacement or as a result of user manipulations. </remark>

Returns

◆ IsolateTextSegments()

System::SharedPtr<TextSegmentCollection> Aspose::Pdf::Text::TextFragment::IsolateTextSegments ( int32_t  startIndex,
int32_t  length 
)

Gets TextSegment(s) representing specified part of the TextFragment text.

Parameters
startIndexPosition in text from which new TextSegment(s) will start.
lengthLength of the text that will isolated into TextSegment(s).
Returns
TextSegmentCollection containing text segments represeting text substring starting at a specifing position and having a specified length.

◆ IsolateToSingleSegment()

void Aspose::Pdf::Text::TextFragment::IsolateToSingleSegment ( )
protected

Isolates segments to single segment for simpler editing.

◆ IsolateToText()

void Aspose::Pdf::Text::TextFragment::IsolateToText ( )
protected

Isolates segments to segment that represent the text only. i.e. we Trim from beginning and end

◆ LightWeightTextSetter()

void Aspose::Pdf::Text::TextFragment::LightWeightTextSetter ( System::String  inText)
protected

Set text with no adjustment.

But segment appearing after isolation of the fragment actually may be shifted. It is usefull for cases like changing font size. If you aren't desire any shifts of text please use LightWeightTextSetterWithNoTextShift()

Parameters
inTextString representing new text value.

◆ LightWeightTextSetterWithNoTextShift()

void Aspose::Pdf::Text::TextFragment::LightWeightTextSetterWithNoTextShift ( System::String  inText)
protected

Set text with no adjustment.

And position of text after the fragment will be kept intact.

Parameters
inTextString representing new text value.

◆ ResetTabstops()

void Aspose::Pdf::Text::TextFragment::ResetTabstops ( )
protected

◆ Serialize()

virtual void Aspose::Pdf::Text::TextFragment::Serialize ( System::SharedPtr< System::Xml::XmlTextWriter writer)
protectedvirtual

Reimplemented from Aspose::Pdf::BaseParagraph.

Reimplemented in Aspose::Pdf::Heading.

◆ set_AttachedState()

void Aspose::Pdf::Text::TextFragment::set_AttachedState ( Aspose::Pdf::Text::TextState::AttachState  value)
protected

◆ set_BaselinePosition()

void Aspose::Pdf::Text::TextFragment::set_BaselinePosition ( System::SharedPtr< Aspose::Pdf::Text::Position value)

Gets text position for text, represented with TextFragment object. The YIndent of the Position structure represents baseline coordinate of the text fragment.

◆ set_EndNote()

void Aspose::Pdf::Text::TextFragment::set_EndNote ( System::SharedPtr< Note value)

Sets the paragraph end note.(for pdf generation only)

◆ set_FootNote()

void Aspose::Pdf::Text::TextFragment::set_FootNote ( System::SharedPtr< Note value)

Sets the paragraph foot note.(for pdf generation only)

◆ set_Fragments()

void Aspose::Pdf::Text::TextFragment::set_Fragments ( System::SharedPtr< TextFragmentCollection value)
protected

Sets collection that contains current fragment

◆ set_HorizontalAlignment()

virtual void Aspose::Pdf::Text::TextFragment::set_HorizontalAlignment ( Aspose::Pdf::HorizontalAlignment  value)
virtual

Sets a horizontal alignment of text fragment.

Reimplemented from Aspose::Pdf::BaseParagraph.

◆ set_Hyperlink()

virtual void Aspose::Pdf::Text::TextFragment::set_Hyperlink ( System::SharedPtr< Aspose::Pdf::Hyperlink value)
virtual

Sets the fragment hyperlink

Reimplemented from Aspose::Pdf::BaseParagraph.

◆ set_Page()

void Aspose::Pdf::Text::TextFragment::set_Page ( System::SharedPtr< Aspose::Pdf::Page value)
protected

Gets page that contains the TextFragment

The value can be null in case the TextFragment object doesn't belong to any page.

◆ set_Position()

void Aspose::Pdf::Text::TextFragment::set_Position ( System::SharedPtr< Aspose::Pdf::Text::Position value)

Sets text position for text, represented with TextFragment object.

The example demonstrates how to view placement of a text, represented by TextFragment object.

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object to find all "hello world" text occurrences
TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world");
// Accept the absorber for first page
doc.Pages[1].Accept(absorber);
// View text and placement info of first text occurrence
TextFragment firstOccurrence = absorber.TextFragments[1];
Console.Out.WriteLine(string.Format("fragment text: {0}", firstOccurrence.Text));
Console.Out.WriteLine(string.Format("fragment X indent: {0}", firstOccurrence.Position.XIndent));
Console.Out.WriteLine(string.Format("fragment Y indent: {0}", firstOccurrence.Position.YIndent));
See also
TextFragmentAbsorber, Document, TextSegment

◆ set_Rectangle()

void Aspose::Pdf::Text::TextFragment::set_Rectangle ( System::SharedPtr< Aspose::Pdf::Rectangle value)
protected

Gets rectangle of the TextFragment

◆ set_ReplaceOptions()

void Aspose::Pdf::Text::TextFragment::set_ReplaceOptions ( System::SharedPtr< TextReplaceOptions value)
protected

◆ set_Segments()

void Aspose::Pdf::Text::TextFragment::set_Segments ( System::SharedPtr< TextSegmentCollection value)

Gets text segments for current TextFragment.

In a few words, TextSegment objects are children of TextFragment object. Advanced users may access segments directly to perform more complex text edit scenarios. For details, please look at TextFragment object description.

The example demonstrates how to navigate all TextSegment objects inside TextFragment.

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object to find all "hello world" text occurrences
TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world");
// Accept the absorber for first page
doc.Pages[1].Accept(absorber);
// Navigate all text segments and out their text and placement info
foreach (TextSegment segment in absorber.TextFragments[1].Segments)
{
Console.Out.WriteLine(string.Format("segment text: {0}", segment.Text));
Console.Out.WriteLine(string.Format("segment X indent: {0}", segment.Position.XIndent));
Console.Out.WriteLine(string.Format("segment Y indent: {0}", segment.Position.YIndent));
}
See also
TextFragmentAbsorber, Document, TextSegment

◆ set_SegmentsGroupState()

void Aspose::Pdf::Text::TextFragment::set_SegmentsGroupState ( System::SharedPtr< Aspose::Pdf::Engine::CommonData::Text::Segmenting::SegmentsGroupState >  value)
protected

◆ set_Text()

void Aspose::Pdf::Text::TextFragment::set_Text ( System::String  value)

Sets System::String text object that the TextFragment object represents.

The example demonstrates how to search a text and replace first occurrence represented with TextFragment object .

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object to find all "hello world" text occurrences
TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world");
// Accept the absorber for first page
doc.Pages[1].Accept(absorber);
// Change font of the first text occurrence
absorber.TextFragments[1].Text = "hi world";
// Save document
doc.Save(@"D:\Tests\output.pdf");
See also
TextFragmentAbsorber, Document

◆ set_TextState()

void Aspose::Pdf::Text::TextFragment::set_TextState ( System::SharedPtr< TextFragmentState value)
protected

Sets text state for the text that TextFragment object represents.

Provides a way to change following properties of the text: Font FontSize FontStyle ForegroundColor BackgroundColor

The example demonstrates how to change text color and font size of the text with TextState object.

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object to find all "hello world" text occurrences
TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world");
// Accept the absorber for first page
doc.Pages[1].Accept(absorber);
// Change foreground color of the first text occurrence
absorber.TextFragments[1].TextState.ForegroundColor = Color.FromRgb(System.Drawing.Color.Red);
// Change font size of the first text occurrence
absorber.TextFragments[1].TextState.FontSize = 15;
// Save document
doc.Save(@"D:\Tests\output.pdf");
See also
TextFragmentAbsorber, Document

◆ set_VerticalAlignment()

virtual void Aspose::Pdf::Text::TextFragment::set_VerticalAlignment ( Aspose::Pdf::VerticalAlignment  value)
virtual

Sets a vertical alignment of text fragment.

Reimplemented from Aspose::Pdf::BaseParagraph.

◆ set_WrapLinesCount()

void Aspose::Pdf::Text::TextFragment::set_WrapLinesCount ( int32_t  value)

Sets wrap lines count for this paragraph(for pdf generation only)

◆ SetEncodedTextProperties()

void Aspose::Pdf::Text::TextFragment::SetEncodedTextProperties ( System::SharedPtr< Font font,
System::String  text,
System::ArrayPtr< int32_t >  indices 
)
protected

Sets font and indices inside the font

Parameters
fontFont of the fragment.
textText value.
indicesGlyph indices inside the font.

◆ SetMarkedContentProperties()

void Aspose::Pdf::Text::TextFragment::SetMarkedContentProperties ( System::String  name,
int32_t  id 
)
protected

◆ SyncHorizontalAlignment()

void Aspose::Pdf::Text::TextFragment::SyncHorizontalAlignment ( Aspose::Pdf::HorizontalAlignment  horizontalAlignment1)
protected

◆ SyncVerticalAlignment()

void Aspose::Pdf::Text::TextFragment::SyncVerticalAlignment ( Aspose::Pdf::VerticalAlignment  verticalAlignment)
protected

Member Data Documentation

◆ OnRectChanged

System::EventHandler Aspose::Pdf::Text::TextFragment::OnRectChanged
protected