property PageCount: Integer;
This read-only property returns the native document page count for ordinary PDFs and the current layout count for active dynamic XFA forms
Since v3.126.1, added and removed XFA page events query the completed layout's total count before notifying OnXfaPageCountChanged; earlier versions could mistake the native event's delta for the total
PageNumberOnXfaPageCountChanged
if Pdf1.Active then
Memo1.Lines.Add('PageCount = ' + IntToStr(Pdf1.PageCount));