Hello,
Thanks for your inquiry.
Sorry that Spire.Pdf doesn’t support getting the backcolor of text, however, I have logged it as a new function into our product updating system with the ticket number SPIREPDF-3193. Our development team will achieve it. Once it is achieved, I will inform you in time. Sorry for the inconvenience caused.
In addition, Spire.Pdf support setting the backcolor for the text you find, I put the code below for your reference.
If you have any issue, just feel free to contact us.
- Code: Select all
//Load the Pdf file
PdfDocument pdfDocument = new PdfDocument();
pdfDocument.LoadFromFile(@"../../data/test.pdf");
PdfPageBase page = pdfDocument.Pages[0];
//Finding the "70%" in pdf file
PdfTextFinder finder = new PdfTextFinder(page);
finder.Options.Parameter = TextFindParameter.IgnoreCase;
List<PdfTextFragment> fragmentsCollection = finder.Find("70%");
//Traveing the result of finding text
foreach (PdfTextFragment fragment in fragmentsCollection)
{
RectangleF rectangleF = fragment.Bounds[0];
//Setting the backcolor
page.Canvas.SetTransparency(1, 1, PdfBlendMode.Multiply);
page.Canvas.DrawRectangle(new PdfSolidBrush(new PdfRGBColor(191, 191, 191)), rectangleF);
}
//Save the result pdf file
pdfDocument.SaveToFile(@"../../output/result.pdf", FileFormat.PDF);
Sincerely
Abel
E-iceblue support team