Page 1 of 1

Search text and draw rectangle problem

Posted: Wed Nov 06, 2013 10:46 am
by pexpoo
Hi all,

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);
                        }

Re: Search text and draw rectangle problem

Posted: Thu Dec 05, 2013 12:34 pm
by Cedric
As you probably know GdPicture.NET 8 branch has been discontinued for quite some time and the PDF text extraction has been greatly enhanced since then.
The only thing I can suggest is to try the latest revision of GdPicture.NET 10 to check if the result is correct and if not, open a support ticket with the needed information for us to investigate.

Cheers