Inheriting text characteristics when replacing text

Hi there!  I'm sure this question must have been asked previously on this forum but I can't find a reference.

I know how to find and replace text using PdfLoadedDocument.  However, is there any way to replace the text without affecting rectangle background and font characteristics?  If not, is there a way to get the characteristics of each rectangle in the text search?  Thanks !


1 Reply

IJ Irfana Jaffer Sadhik Syncfusion Team October 24, 2024 11:55 AM UTC

Hi WindChaser,


After further analyzing your request, we understand that you want to replace text without altering the font characteristics or the background rectangle. While we don't have direct support for this, we have developed a simple workaround with the following steps:


1. Load the document.

2. Find the text and preserve all matching bounds.

3. Iterate through the pages with the matched bounds and use the extract text feature to retrieve the font details.

4. Perform redaction over the matched bounds using the text-only API.

5. Draw the string with the extracted font details over the redacted area.

6. Save the final PDF document.

Please try this on your end and let us know the outcome.




Please follow the below links for more information:

Regards,
Irfana J


Loader.
Up arrow icon