1.I have tried to search text in all pages
2.then draw rectangle (highlight search text)
3.and save to new PDF.
My problem is some of PDF files rectangle position are not correct.But many PDF files are correct.
And I think GdPicturePDF.SearchText method give me correct left and top.
I use GdPicture 8.5.0.18 .Please help.
Code: Select all
GdPicturePDF gdPDF = new GdPicturePDF();
MemStream = new MemoryStream(ContentBytes);
if (gdPDF.LoadFromStream(MemStream) == GdPictureStatus.OK)
{
int pageCount = gdPDF.GetPageCount();
for (int i = 1; i <= pageCount; i++)
{
bool found;
int Occur = 1;
gdPDF.SelectPage(i);
do
{
float left = 0, top = 0, width = 0, height = 0;
// Search
found = gdPDF.SearchText(searchWord, Occur, false, true, ref left, ref top, ref width, ref height);
if (found)
{
firstAtFoundPage.Add(i);
gdPDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch);
gdPDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdPDF.SetLineColor(0, 0, 255);
gdPDF.DrawRectangle(left, top, width, height, false, true);
Occur++;
}
} while (found);
}