Aspose::Pdf::Text::TextFragmentAbsorber Class Referencefinal

Represents an absorber object of text fragments. Performs text search and provides access to search results via TextFragmentAbsorber::TextFragments collection. More...

Inherits Aspose::Pdf::Text::TextAbsorber.

Public Member Functions

System::SharedPtr< TextFragmentCollectionget_TextFragments ()
 Gets collection of search occurrences that are presented with TextFragment objects. More...
 
void set_TextFragments (System::SharedPtr< TextFragmentCollection > value)
 Gets collection of search occurrences that are presented with TextFragment objects. More...
 
System::String get_Phrase ()
 Gets phrase that the TextFragmentAbsorber searches on the PDF document or page. More...
 
void set_Phrase (System::String value)
 Sets phrase that the TextFragmentAbsorber searches on the PDF document or page. More...
 
System::SharedPtr< Aspose::Pdf::Text::TextSearchOptionsget_TextSearchOptions ()
 Gets search options. The options enable search using regular expressions. More...
 
void set_TextSearchOptions (System::SharedPtr< Aspose::Pdf::Text::TextSearchOptions > value)
 Sets search options. The options enable search using regular expressions. More...
 
System::SharedPtr< Aspose::Pdf::Text::TextEditOptionsget_TextEditOptions ()
 Gets text edit options. The options define special behavior when requested symbol cannot be written with font. More...
 
void set_TextEditOptions (System::SharedPtr< Aspose::Pdf::Text::TextEditOptions > value)
 Sets text edit options. The options define special behavior when requested symbol cannot be written with font. More...
 
System::SharedPtr< Aspose::Pdf::Text::TextReplaceOptionsget_TextReplaceOptions ()
 Gets text replace options. The options define behavior when text fragment is replaced to more short. More...
 
void set_TextReplaceOptions (System::SharedPtr< Aspose::Pdf::Text::TextReplaceOptions > value)
 Sets text replace options. The options define behavior when text fragment is replaced to more short. More...
 
bool get_HasErrors ()
 Value indicates whether errors were found during text extraction. Searching for errors will performed only if TextSearchOptions.LogTextExtractionErrors = true; And it may decrease performance. More...
 
System::SharedPtr< System::Collections::Generic::List< System::SharedPtr< TextExtractionError > > > get_Errors ()
 List of TextExtractionError objects. It contain information about errors were found during text extraction. Searching for errors will performed only if TextSearchOptions.LogTextExtractionErrors = true; And it may decrease performance. More...
 
virtual System::String get_Text ()
 Gets extracted text that the TextAbsorber extracts on the PDF document or page. More...
 
virtual System::SharedPtr< TextExtractionOptionsget_ExtractionOptions ()
 Gets text extraction options. More...
 
virtual void set_ExtractionOptions (System::SharedPtr< TextExtractionOptions > value)
 Sets text extraction options. More...
 
 TextFragmentAbsorber ()
 Initializes a new instance of the TextFragmentAbsorber that performs search of all text segments of the document or page. More...
 
 TextFragmentAbsorber (System::SharedPtr< Aspose::Pdf::Text::TextEditOptions > textEditOptions)
 Initializes a new instance of the TextFragmentAbsorber with text edit options, that performs search of all text segments of the document or page. More...
 
 TextFragmentAbsorber (System::String phrase)
 Initializes a new instance of the TextFragmentAbsorber class for the specified text phrase. More...
 
 TextFragmentAbsorber (System::SharedPtr< System::Text::RegularExpressions::Regex > regex)
 Initializes a new instance of the TextFragmentAbsorber class for the specified System.Text.RegularExpressions.Regex class object. More...
 
 TextFragmentAbsorber (System::String phrase, System::SharedPtr< Aspose::Pdf::Text::TextSearchOptions > textSearchOptions)
 Initializes a new instance of the TextFragmentAbsorber class for the specified text phrase and text search options. More...
 
 TextFragmentAbsorber (System::SharedPtr< System::Text::RegularExpressions::Regex > regex, System::SharedPtr< Aspose::Pdf::Text::TextSearchOptions > textSearchOptions)
 Initializes a new instance of the TextFragmentAbsorber class for the specified text phrase and text search options. More...
 
 TextFragmentAbsorber (System::String phrase, System::SharedPtr< Aspose::Pdf::Text::TextSearchOptions > textSearchOptions, System::SharedPtr< Aspose::Pdf::Text::TextEditOptions > textEditOptions)
 Initializes a new instance of the TextFragmentAbsorber class for the specified text phrase, text search options and text edit options. More...
 
 TextFragmentAbsorber (System::String phrase, System::SharedPtr< Aspose::Pdf::Text::TextEditOptions > textEditOptions)
 Initializes a new instance of the TextFragmentAbsorber class for the specified text phrase and text edit options. More...
 
 TextFragmentAbsorber (System::SharedPtr< System::Text::RegularExpressions::Regex > regex, System::SharedPtr< Aspose::Pdf::Text::TextEditOptions > textEditOptions)
 Initializes a new instance of the TextFragmentAbsorber class for the specified text phrase and text edit options. More...
 
virtual void Visit (System::SharedPtr< Page > page)
 Performs search on the specified page. More...
 
virtual void Visit (System::SharedPtr< Document > pdf)
 Performs search on the specified document. More...
 
void ApplyForAllFragments (System::SharedPtr< Font > font)
 Applies font for all text fragments that were absorbed. It works faster than looping through the fragments if all fragments on the page(s) were absorbed. Otherwise it works similar with looping. More...
 
void ApplyForAllFragments (float fontSize)
 Applies font size for all text fragments that were absorbed. It works faster than looping through the fragments if all fragments on the page(s) were absorbed. Otherwise it works similar with looping. More...
 
void ApplyForAllFragments (System::SharedPtr< Font > font, float fontSize)
 Applies font and size for all text fragments that were absorbed. It works faster than looping through the fragments if all fragments on the page(s) were absorbed. Otherwise it works similar with looping. More...
 
void Reset ()
 Clears TextFragments collection of this TextFragmentAbsorber object. More...
 
void RemoveAllText (System::SharedPtr< Page > page)
 Removes all text from the specified page. More...
 
void RemoveAllText (System::SharedPtr< Page > page, System::SharedPtr< Rectangle > rect)
 Removes text inside the specified rectangle from the specified page. More...
 
void RemoveAllText (System::SharedPtr< Document > document)
 Removes all text from the document. More...
 
void Visit (System::SharedPtr< XForm > xForm)
 Performs search on the specified form object. More...
 
- Public Member Functions inherited from Aspose::Pdf::Text::TextAbsorber
bool get_HasErrors ()
 Value indicates whether errors were found during text extraction. Searching for errors will performed only if TextSearchOptions.LogTextExtractionErrors = true; And it may decrease performance. More...
 
System::SharedPtr< System::Collections::Generic::List< System::SharedPtr< TextExtractionError > > > get_Errors ()
 List of TextExtractionError objects. It contain information about errors were found during text extraction. Searching for errors will performed only if TextSearchOptions.LogTextExtractionErrors = true; And it may decrease performance. More...
 
 TextAbsorber ()
 Initializes a new instance of the TextAbsorber. More...
 
 TextAbsorber (System::SharedPtr< TextExtractionOptions > extractionOptions)
 Initializes a new instance of the TextAbsorber with extraction options. More...
 
 TextAbsorber (System::SharedPtr< TextExtractionOptions > extractionOptions, System::SharedPtr< Aspose::Pdf::Text::TextSearchOptions > textSearchOptions)
 Initializes a new instance of the TextAbsorber with extraction and text search options. More...
 
 TextAbsorber (System::SharedPtr< Aspose::Pdf::Text::TextSearchOptions > textSearchOptions)
 Initializes a new instance of the TextAbsorber with text search options. More...
 
- 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)
 

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...
 
- Protected Member Functions inherited from Aspose::Pdf::Text::TextAbsorber
System::String GetTotalText (System::SharedPtr< Aspose::Pdf::Engine::CommonData::Text::Segmenting::TextSegmenter > segmenter, bool isFormatted)
 
- Protected Attributes inherited from Aspose::Pdf::Text::TextAbsorber
System::SharedPtr< System::Text::StringBuilderextractedText
 

Detailed Description

Represents an absorber object of text fragments. Performs text search and provides access to search results via TextFragmentAbsorber::TextFragments collection.

The TextFragmentAbsorber object is basically used in text search scenario. When the search is completed the occurrences are represented with TextFragment objects that the TextFragmentAbsorber::TextFragments collection contains. The TextFragment object provides access to the search occurrence text, text properties, and allows to edit text and change the text state (font, font size, color etc).

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

◆ TextFragmentAbsorber() [1/9]

Aspose::Pdf::Text::TextFragmentAbsorber::TextFragmentAbsorber ( )

Initializes a new instance of the TextFragmentAbsorber that performs search of all text segments of the document or page.

Performs text search and provides access to search results via TextFragmentAbsorber::TextFragments collection.

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

// 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
// Make the absorber to search all "hello world" text occurrences
absorber.Phrase = "hello world";
// Accept the absorber for first page
doc.Pages[1].Accept(absorber);
// Change text of the first text occurrence
absorber.TextFragments[1].Text = "hi world";
// Save document
doc.Save(@"D:\Tests\output.pdf");

◆ TextFragmentAbsorber() [2/9]

Aspose::Pdf::Text::TextFragmentAbsorber::TextFragmentAbsorber ( System::SharedPtr< Aspose::Pdf::Text::TextEditOptions textEditOptions)

Initializes a new instance of the TextFragmentAbsorber with text edit options, that performs search of all text segments of the document or page.

Performs text search and provides access to search results via TextFragmentAbsorber::TextFragments collection.

The example demonstrates how to find all text fragments on the first PDF document page and replace font for them.

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object
TextFragmentAbsorber absorber = new TextFragmentAbsorber(new TextEditOptions(TextEditOptions.FontReplace.RemoveUnusedFonts));
// Accept the absorber for first page
doc.Pages[1].Accept(absorber);
// Find Courier font
Pdf.Text.Font font = FontRepository.FindFont("Courier");
// Set the font for all the text fragments
foreach (TextFragment textFragment in absorber.TextFragments)
{
textFragment.TextState.Font = font;
}
// Save document
doc.Save(@"D:\Tests\output.pdf");
Parameters
textEditOptionsText edit options (Allows to turn on some edit features).

◆ TextFragmentAbsorber() [3/9]

Aspose::Pdf::Text::TextFragmentAbsorber::TextFragmentAbsorber ( System::String  phrase)

Initializes a new instance of the TextFragmentAbsorber class for the specified text phrase.

Performs text search of the specified phrase and provides access to search results via TextFragmentAbsorber::TextFragments collection.

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");
Parameters
phrasePhrase that the TextFragmentAbsorber searches

◆ TextFragmentAbsorber() [4/9]

Aspose::Pdf::Text::TextFragmentAbsorber::TextFragmentAbsorber ( System::SharedPtr< System::Text::RegularExpressions::Regex regex)

Initializes a new instance of the TextFragmentAbsorber class for the specified System.Text.RegularExpressions.Regex class object.

Performs text search of the specified phrase and provides access to search results via TextFragmentAbsorber::TextFragments collection.

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 TextAbsorber object to find all instances of the input regex
// Accept the absorber for first page
doc.Pages[1].Accept(absorber);
// we should find "hello" word and replace it with "Hi"
doc.Pages[1].Accept(absorber);
absorber.TextFragments[1].Text = "Hi";
// Save document
doc.Save(@"D:\Tests\output.pdf");
Parameters
regexSystem.Text.RegularExpressions.Regex class object that the TextFragmentAbsorber searches

◆ TextFragmentAbsorber() [5/9]

Aspose::Pdf::Text::TextFragmentAbsorber::TextFragmentAbsorber ( System::String  phrase,
System::SharedPtr< Aspose::Pdf::Text::TextSearchOptions textSearchOptions 
)

Initializes a new instance of the TextFragmentAbsorber class for the specified text phrase and text search options.

Performs text search of the specified phrase and provides access to search results via TextFragmentAbsorber::TextFragments collection.

The example demonstrates how to find text with regular expression on the first PDF document page and replace the text.

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object that searches all words starting 'h' and ending 'o' using regular expression.
TextFragmentAbsorber absorber = new TextFragmentAbsorber(@"h\w*?o", new TextSearchOptions(true));
// we should find "hello" word and replace it with "Hi"
doc.Pages[1].Accept(absorber);
absorber.TextFragments[1].Text = "Hi";
// Save document
doc.Save(@"D:\Tests\output.pdf");
Parameters
phrasePhrase that the TextFragmentAbsorber searches
textSearchOptionsText search options (Allows to turn on some search features. For example, search with regular expression)

◆ TextFragmentAbsorber() [6/9]

Aspose::Pdf::Text::TextFragmentAbsorber::TextFragmentAbsorber ( System::SharedPtr< System::Text::RegularExpressions::Regex regex,
System::SharedPtr< Aspose::Pdf::Text::TextSearchOptions textSearchOptions 
)

Initializes a new instance of the TextFragmentAbsorber class for the specified text phrase and text search options.

Performs text search of the specified phrase and provides access to search results via TextFragmentAbsorber::TextFragments collection.

The example demonstrates how to find text with regular expression on the first PDF document page and replace the text.

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object that searches all words starting 'h' and ending 'o' using regular expression.
TextFragmentAbsorber absorber = new TextFragmentAbsorber(new System.Text.RegularExpressions.Regex(@"h\w*?o"), new TextSearchOptions(true));
// we should find "hello" word and replace it with "Hi"
doc.Pages[1].Accept(absorber);
absorber.TextFragments[1].Text = "Hi";
// Save document
doc.Save(@"D:\Tests\output.pdf");
Parameters
regexSystem.Text.RegularExpressions.Regex class object that the TextFragmentAbsorber searches
textSearchOptionsText search options (Allows to turn on some search features.)

◆ TextFragmentAbsorber() [7/9]

Aspose::Pdf::Text::TextFragmentAbsorber::TextFragmentAbsorber ( System::String  phrase,
System::SharedPtr< Aspose::Pdf::Text::TextSearchOptions textSearchOptions,
System::SharedPtr< Aspose::Pdf::Text::TextEditOptions textEditOptions 
)

Initializes a new instance of the TextFragmentAbsorber class for the specified text phrase, text search options and text edit options.

Performs text search of the specified phrase and provides access to search results via TextFragmentAbsorber::TextFragments collection.

The example demonstrates how to find text with regular expression on the first PDF document page and replace the text.

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object that searches all words starting 'h' and ending 'o' using regular expression.
TextFragmentAbsorber absorber = new TextFragmentAbsorber(@"h\w*?o", new TextSearchOptions(true));
// we should find "hello" word and replace it with "Hi"
doc.Pages[1].Accept(absorber);
absorber.TextFragments[1].Text = "Hi";
// Save document
doc.Save(@"D:\Tests\output.pdf");
Parameters
phrasePhrase that the TextFragmentAbsorber searches
textSearchOptionsText search options (Allows to turn on some search features. For example, search with regular expression)
textEditOptionsText edit options (Allows to turn on some edit features).

◆ TextFragmentAbsorber() [8/9]

Aspose::Pdf::Text::TextFragmentAbsorber::TextFragmentAbsorber ( System::String  phrase,
System::SharedPtr< Aspose::Pdf::Text::TextEditOptions textEditOptions 
)

Initializes a new instance of the TextFragmentAbsorber class for the specified text phrase and text edit options.

Performs text search of the specified phrase and provides access to search results via TextFragmentAbsorber::TextFragments collection.

Parameters
phrasePhrase that the TextFragmentAbsorber searches
textEditOptionsText edit options (Allows to turn on some edit features).

◆ TextFragmentAbsorber() [9/9]

Aspose::Pdf::Text::TextFragmentAbsorber::TextFragmentAbsorber ( System::SharedPtr< System::Text::RegularExpressions::Regex regex,
System::SharedPtr< Aspose::Pdf::Text::TextEditOptions textEditOptions 
)

Initializes a new instance of the TextFragmentAbsorber class for the specified text phrase and text edit options.

Performs text search of the specified phrase and provides access to search results via TextFragmentAbsorber::TextFragments collection.

Parameters
regexSystem.Text.RegularExpressions.Regex class object that the TextFragmentAbsorber searches
textEditOptionsText edit options (Allows to turn on some edit features).

Member Function Documentation

◆ ApplyForAllFragments() [1/3]

void Aspose::Pdf::Text::TextFragmentAbsorber::ApplyForAllFragments ( System::SharedPtr< Font font)

Applies font for all text fragments that were absorbed. It works faster than looping through the fragments if all fragments on the page(s) were absorbed. Otherwise it works similar with looping.

Parameters
fontFontof the text.

◆ ApplyForAllFragments() [2/3]

void Aspose::Pdf::Text::TextFragmentAbsorber::ApplyForAllFragments ( float  fontSize)

Applies font size for all text fragments that were absorbed. It works faster than looping through the fragments if all fragments on the page(s) were absorbed. Otherwise it works similar with looping.

Parameters
fontSizeFont size of the text.

◆ ApplyForAllFragments() [3/3]

void Aspose::Pdf::Text::TextFragmentAbsorber::ApplyForAllFragments ( System::SharedPtr< Font font,
float  fontSize 
)

Applies font and size for all text fragments that were absorbed. It works faster than looping through the fragments if all fragments on the page(s) were absorbed. Otherwise it works similar with looping.

Parameters
fontFontof the text.
fontSizeFont size of the text.

◆ get_Errors()

System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<TextExtractionError> > > Aspose::Pdf::Text::TextFragmentAbsorber::get_Errors ( )

List of TextExtractionError objects. It contain information about errors were found during text extraction. Searching for errors will performed only if TextSearchOptions.LogTextExtractionErrors = true; And it may decrease performance.

◆ get_ExtractionOptions()

virtual System::SharedPtr<TextExtractionOptions> Aspose::Pdf::Text::TextFragmentAbsorber::get_ExtractionOptions ( )
virtual

Gets text extraction options.

Reimplemented from Aspose::Pdf::Text::TextAbsorber.

◆ get_HasErrors()

bool Aspose::Pdf::Text::TextFragmentAbsorber::get_HasErrors ( )

Value indicates whether errors were found during text extraction. Searching for errors will performed only if TextSearchOptions.LogTextExtractionErrors = true; And it may decrease performance.

◆ get_Phrase()

System::String Aspose::Pdf::Text::TextFragmentAbsorber::get_Phrase ( )

Gets phrase that the TextFragmentAbsorber searches on the PDF document or page.

The example demonstrates how to perform search text several times and perform text replacements.

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object to find all "hello" text occurrences
doc.Pages[1].Accept(absorber);
absorber.TextFragments[1].Text = "Hi";
// search another word and replace it
absorber.Phrase = "world";
doc.Pages[1].Accept(absorber);
absorber.TextFragments[1].Text = "John";
// Save document
doc.Save(@"D:\Tests\output.pdf");

◆ get_Text()

virtual System::String Aspose::Pdf::Text::TextFragmentAbsorber::get_Text ( )
virtual

Gets extracted text that the TextAbsorber extracts on the PDF document or page.

Reimplemented from Aspose::Pdf::Text::TextAbsorber.

◆ get_TextEditOptions()

System::SharedPtr<Aspose::Pdf::Text::TextEditOptions> Aspose::Pdf::Text::TextFragmentAbsorber::get_TextEditOptions ( )

Gets text edit options. The options define special behavior when requested symbol cannot be written with font.

◆ get_TextFragments()

System::SharedPtr<TextFragmentCollection> Aspose::Pdf::Text::TextFragmentAbsorber::get_TextFragments ( )

Gets collection of search occurrences that are presented with TextFragment objects.

The example demonstrates how to find text on the first PDF document page and replace all search occurrences with new text.

// 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 of all search occurrences
foreach (TextFragment textFragment in absorber.TextFragments)
{
textFragment.Text = "hi world";
}
// Save document
doc.Save(@"D:\Tests\output.pdf");

◆ get_TextReplaceOptions()

System::SharedPtr<Aspose::Pdf::Text::TextReplaceOptions> Aspose::Pdf::Text::TextFragmentAbsorber::get_TextReplaceOptions ( )

Gets text replace options. The options define behavior when text fragment is replaced to more short.

◆ get_TextSearchOptions()

System::SharedPtr<Aspose::Pdf::Text::TextSearchOptions> Aspose::Pdf::Text::TextFragmentAbsorber::get_TextSearchOptions ( )
virtual

Gets search options. The options enable search using regular expressions.

The example demonstrates how to perform search text using regular expression.

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object
// make the absorber to search all words starting 'h' and ending 'o' using regular expression.
absorber.Phrase = @"h\w*?o";
absorber.TextSearchOptions = new TextSearchOptions(true);
// we should find "hello" word and replace it with "Hi"
doc.Pages[1].Accept(absorber);
absorber.TextFragments[1].Text = "Hi";
// Save document
doc.Save(@"D:\Tests\output.pdf");

Reimplemented from Aspose::Pdf::Text::TextAbsorber.

◆ RemoveAllText() [1/3]

void Aspose::Pdf::Text::TextFragmentAbsorber::RemoveAllText ( System::SharedPtr< Page page)

Removes all text from the specified page.

Parameters
pagePDF document page object.

◆ RemoveAllText() [2/3]

void Aspose::Pdf::Text::TextFragmentAbsorber::RemoveAllText ( System::SharedPtr< Page page,
System::SharedPtr< Rectangle rect 
)

Removes text inside the specified rectangle from the specified page.

Parameters
pagePDF document page object.
rectRectangle to remove text inside.

◆ RemoveAllText() [3/3]

void Aspose::Pdf::Text::TextFragmentAbsorber::RemoveAllText ( System::SharedPtr< Document document)

Removes all text from the document.

Parameters
documentPDF document object.

◆ Reset()

void Aspose::Pdf::Text::TextFragmentAbsorber::Reset ( )

Clears TextFragments collection of this TextFragmentAbsorber object.

◆ set_ExtractionOptions()

virtual void Aspose::Pdf::Text::TextFragmentAbsorber::set_ExtractionOptions ( System::SharedPtr< TextExtractionOptions value)
virtual

Sets text extraction options.

Reimplemented from Aspose::Pdf::Text::TextAbsorber.

◆ set_Phrase()

void Aspose::Pdf::Text::TextFragmentAbsorber::set_Phrase ( System::String  value)

Sets phrase that the TextFragmentAbsorber searches on the PDF document or page.

The example demonstrates how to perform search text several times and perform text replacements.

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object to find all "hello" text occurrences
doc.Pages[1].Accept(absorber);
absorber.TextFragments[1].Text = "Hi";
// search another word and replace it
absorber.Phrase = "world";
doc.Pages[1].Accept(absorber);
absorber.TextFragments[1].Text = "John";
// Save document
doc.Save(@"D:\Tests\output.pdf");

◆ set_TextEditOptions()

void Aspose::Pdf::Text::TextFragmentAbsorber::set_TextEditOptions ( System::SharedPtr< Aspose::Pdf::Text::TextEditOptions value)

Sets text edit options. The options define special behavior when requested symbol cannot be written with font.

◆ set_TextFragments()

void Aspose::Pdf::Text::TextFragmentAbsorber::set_TextFragments ( System::SharedPtr< TextFragmentCollection value)

Gets collection of search occurrences that are presented with TextFragment objects.

The example demonstrates how to find text on the first PDF document page and replace all search occurrences with new text.

// 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 of all search occurrences
foreach (TextFragment textFragment in absorber.TextFragments)
{
textFragment.Text = "hi world";
}
// Save document
doc.Save(@"D:\Tests\output.pdf");

◆ set_TextReplaceOptions()

void Aspose::Pdf::Text::TextFragmentAbsorber::set_TextReplaceOptions ( System::SharedPtr< Aspose::Pdf::Text::TextReplaceOptions value)

Sets text replace options. The options define behavior when text fragment is replaced to more short.

◆ set_TextSearchOptions()

void Aspose::Pdf::Text::TextFragmentAbsorber::set_TextSearchOptions ( System::SharedPtr< Aspose::Pdf::Text::TextSearchOptions value)
virtual

Sets search options. The options enable search using regular expressions.

The example demonstrates how to perform search text using regular expression.

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object
// make the absorber to search all words starting 'h' and ending 'o' using regular expression.
absorber.Phrase = @"h\w*?o";
absorber.TextSearchOptions = new TextSearchOptions(true);
// we should find "hello" word and replace it with "Hi"
doc.Pages[1].Accept(absorber);
absorber.TextFragments[1].Text = "Hi";
// Save document
doc.Save(@"D:\Tests\output.pdf");

Reimplemented from Aspose::Pdf::Text::TextAbsorber.

◆ Visit() [1/3]

virtual void Aspose::Pdf::Text::TextFragmentAbsorber::Visit ( System::SharedPtr< Page page)
virtual

Performs search on the specified page.

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

// 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
absorber.Visit(doc.Pages[1]);
// Change text of all search occurrences
foreach (TextFragment textFragment in absorber.TextFragments)
{
textFragment.Text = "hi world";
}
// Save document
doc.Save(@"D:\Tests\output.pdf");
Parameters
pagePDF document page object.

Reimplemented from Aspose::Pdf::Text::TextAbsorber.

◆ Visit() [2/3]

virtual void Aspose::Pdf::Text::TextFragmentAbsorber::Visit ( System::SharedPtr< Document pdf)
virtual

Performs search on the specified document.

The example demonstrates how to find text on PDF document and replace text of all search occurrences.

// 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
absorber.Visit(doc);
// Change text of the first text occurrence
absorber.TextFragments[1].Text = "hi world";
// Save document
doc.Save(@"D:\Tests\output.pdf");
Parameters
pdfPDF document object.

Reimplemented from Aspose::Pdf::Text::TextAbsorber.

◆ Visit() [3/3]

void Aspose::Pdf::Text::TextFragmentAbsorber::Visit ( System::SharedPtr< XForm xForm)
virtual

Performs search on the specified form object.

Parameters
xFormPdf form object.

Reimplemented from Aspose::Pdf::Text::TextAbsorber.