I was trying to replace a text which has 17 0’s. Replacing the text is successful. But,
- It added a background colour to the replaced text element, and
- the next element to the replaced text is a bar code which is broken in this process. (try t scan the barcode in input and output files)
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()
{
string dataDir = @"...\text\";
Document pdfDocument = new Document(dataDir + "input.pdf");
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("00000000000000000");
pdfDocument.Pages.Accept(textFragmentAbsorber);
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
foreach (TextFragment textFragment in textFragmentCollection)
{
textFragment.Text = "1V1VV57772Y200002";
}
pdfDocument.Save(dataDir + "output.pdf");
}
Sample input and output files :
Audi VIN 114x42 Germany.pdf (131.1 KB)
output.pdf (212.6 KB)