We are going to purchase this tool for one of our client soon, i have downloaded trial version i want to replace particular text in whole pdf document.
I have tried the code from Apose documentation i am getting error for “Runexample” for path, saying object not found.
I have worked with the below code snippet from API documentation and it is working fine. You may use below code from this documentation article and modify it as per your requirements. I have attached the source and generated PDF files for your kind reference. ReplaceTextAll_17.12.pdfReplaceTextAll.pdf
// Open document
Document pdfDocument = new Document(dataDir + "ReplaceTextAll.pdf");
// Create TextAbsorber object to find all instances of the input search phrase
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("text");
// Accept the absorber for all the pages
pdfDocument.Pages.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 = "TEXT";
//textFragment.TextState.Font = FontRepository.FindFont("Verdana");
//textFragment.TextState.FontSize = 22;
//textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Blue);
//textFragment.TextState.BackgroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Green);
}
dataDir = dataDir + "ReplaceTextAll_17.12.pdf";
// Save resulting PDF document.
pdfDocument.Save(dataDir);
You may visit this documentation article to avoid any issue while executing any code snippet from our examples.
I would like to request you to always create separate topics for separate issues. Kindly create a new topic while sharing your source and generated PDF file along with a narrowed down code snippet reproducing this issue. Before sharing requested data, please ensure using Aspose.PDF for .NET 18.2 in your environment.