Hello ASPOSE,
is there a way to find a text on PDF page and to move this text to another position in this page?
Regards
Gerd
Hi Gerd,
string append_move_with = “versions of Lorem Ipsum”;
// Open document
Document pdfDocument = new Document(dataDir + “pdfsamplefile.pdf”);
// Create TextAbsorber object to find all instances of the input search phrase
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(findWord);
// Accept the absorber for all the pages
pdfDocument.Pages[1].Accept(textFragmentAbsorber);
// Get the extracted text fragments
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
// Loop through the fragments
foreach (TextFragment textFragment in textFragmentCollection)
{
// Update text and other properties
textFragment.Text = “”;
}
TextFragmentAbsorber textFragmentAbsorber1 = new TextFragmentAbsorber(append_move_with);
// Accept the absorber for all the pages
pdfDocument.Pages[1].Accept(textFragmentAbsorber1);
// Get the extracted text fragments
TextFragmentCollection textFragmentCollection1 = textFragmentAbsorber1.TextFragments;
// Loop through the fragments
foreach (TextFragment textFragment in textFragmentCollection1)
{
// Update text and other properties
textFragment.Text = append_move_with + ’ ' + findWord;
}
dataDir = dataDir + “output_file.pdf”;
// Save resulting PDF document.
pdfDocument.Save(dataDir);