ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 PdfViewer.SaveToFile - wrong z-index
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

aleatprog

149 Posts

Posted - Apr 21 2026 :  08:49:14  Show Profile  Reply
Hello,

after executing the following code, ImageEnView1.PdfViewer visualizes correctly yellow rectangles under all search results, meanwhile in the exported PDF file, the yellow rectangles are above the search results, not highlighting but covering them.

ImageEnView1.PdfViewer.Enabled := True;
ImageEnView1.PdfViewer.AllowObjectEditing := True;
ImageEnView1.PdfViewer.LoadFromFile(Path + 'input.pdf');
for i := 0 to ImageEnView1.PdfViewer.PageCount - 1 do
  begin
    ImageEnView1.PdfViewer.PageIndex := i;
    if ImageEnView1.PdfViewer.Find(SearchBox.Text, wordIdx, wordLen, False, False, False, False) then
      begin
        rectArray := ImageEnView1.PDFViewer.GetTextRects(wordIdx, wordLen, 3, False);
        ImageEnView1.PdfViewer.FindNext(wordIdx, wordLen, False, False);
        rectArray := rectArray + ImageEnView1.PDFViewer.GetTextRects(wordIdx, wordLen, 3, False);
        for j := 0 to High(rectArray) do
          begin
            rect := rectArray[j];
            ImageEnView1.PdfViewer.Objects.AddRect(rect.Left, rect.Top, rect.Width, rect.Height, clYellow, 1.0, 1.0, True, clYellow, 1.0, True, 0);
          end;
        ImageEnView1.PdfViewer.ApplyChanges();
      end;
  end;
ImageEnView1.PdfViewer.SaveToFile(Path + 'output.pdf');


Like in topic "PdfViewer.Objects.RemoveObject - edited PDF saved with collapsed structure", also in this case the wrong visualisation (rectangle above text) becomes permanent in ImageEnView1.PdfViewer by loading another page.

Ale

xequte

39397 Posts

Posted - Apr 27 2026 :  22:57:27  Show Profile  Reply
Hi Ale

Unfortunately that seems to be an issue in the way the PDFium library renders pending object changes. If you add:
ImageEnView1.PdfViewer.ReloadPage();

After:
ImageEnView1.PdfViewer.ApplyChanges();

It renders as per the final output.


Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: