I was trying to replace a text which has a border line at its bottom. Replacing the text is successful. But,
the border line is broken.
My Environment Details are
Windows 10 Enterprise 21H2 64 Bit
Intel® - Xenon® Gold 6254 CPU @ 3.10GHZ
Microsoft Visual Studio Professional 2022 Version 17.2.0
Dot Net 6.0
ASPOSE.PDF latest version 23.5.0
public static void FindAndReplace()
{
dataDir = @"...\text\";
Document pdfDocument = new Document(dataDir + "Towing.pdf");
List<FindAndReplaceRequestObject> inputsList = new() {
new FindAndReplaceRequestObject {searchText = "Gasoline", replacementText = "Electric"}, // input_1
new FindAndReplaceRequestObject {searchText = "de remorque", replacementText = "remorque"}, // input_2
};
foreach (var item in inputsList)
{
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(item.searchText);
pdfDocument.Pages.Accept(textFragmentAbsorber);
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
foreach (TextFragment textFragment in textFragmentCollection)
{
textFragment.Text = item.replacementText;
}
}
pdfDocument.Save(dataDir + @"textreplaceoutputs\Towing_latest_Out_For.pdf");
}
public class FindAndReplaceRequestObject
{
public string searchText { get; set; }
public string replacementText { get; set; }
}
Sample input and output files :
input_1.pdf (271.3 KB)
input_2.pdf (240.2 KB)
output_1.pdf (353.7 KB)
output_2.pdf (313.9 KB)