Hello,
We’re trying to update the text from the existing PDF we’re able to update the text but when we check the accessibility of PDF in Adobe reader it shows the error regarding character encoding failed. Please see image.png (101.9 KB)
But the original PDF doesn’t contains this error. Please see image.png (102.8 KB)
. The code we’re using here to find and replace the text is as below.
// Instantiate Document object
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(fileStream);
string personalisedString = “Forrester Report Prepared For ###fullName### With ###organization###”.Replace("###fullName###", “Jignesh”).Replace("###organization###", “Savaliya”);
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(“Forrester Report Prepared For ###fullName### With ###organization###”);
doc.Pages.Accept(textFragmentAbsorber);
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
// Loop through the fragments
foreach (TextFragment textFragment in textFragmentCollection)
{
textFragment.Text = personalisedString;
}
using (MemoryStream stream = new MemoryStream())
{
doc.Save(stream, SaveFormat.Pdf);
var file = ConvertStreamToBytes(stream);
return File(file, “application/pdf”, pdfName);
}
Also attaching both the file.
- Existing file: BASE PDF AMY_DTESTReport_with_VideoBuilding_Brands_With_Enduring_Resonance.pdf (701.5 KB)
- Updated file: Personalised AMY DTESTReport with VideoBuilding Brands With Enduring Resonance.pdf (708.5 KB)
Regards,
Synoptek