Hi,
Can you send me a sample code where I can search for text and then replace that text with a strikeout text.
Thank you
//Load Pdf document
PdfDocument doc = new PdfDocument("test.pdf");
//Define a brush
PdfBrush brush = new PdfSolidBrush(Color.Black);
//Define a font with Strikeout style
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", 9f, FontStyle.Strikeout));
String text = "TEST";
//Loop through pages
foreach (PdfPageBase page in doc.Pages)
{
//Find text
Spire.Pdf.General.Find.PdfTextFind[] finds = page.FindText(text, TextFindParameter.WholeWord).Finds;
//Loop through found texts
foreach (Spire.Pdf.General.Find.PdfTextFind seletion in finds)
{
List<RectangleF> textBounds = seletion.TextBounds;
RectangleF rec = seletion.TextBounds[0];
page.Canvas.DrawRectangle(PdfBrushes.White, rec);
//Draw the text with Strikeout style
page.Canvas.DrawString(text, font, brush, rec.X, rec.Y);
}
}
//Save the document
doc.SaveToFile("result.pdf",FileFormat.PDF);