page property
PdfPage?
get
page
Gets the page of the field.
Implementation
PdfPage? get page {
if (_page == null) {
final PdfFieldHelper helper = PdfFieldHelper.getHelper(_helper.field);
final int backUpIndex = helper.defaultIndex;
helper.defaultIndex = _helper._collectionIndex;
_page = _helper.field.page;
final PdfName pName = PdfName(PdfDictionaryProperties.p);
final PdfArray? kids = helper.kids;
if (kids != null && kids.count > 0) {
final PdfCrossTable crosstable = helper.crossTable!;
final PdfDocument? doc = crosstable.document;
if (doc != null && PdfDocumentHelper.getHelper(doc).isLoadedDocument) {
if (_helper.dictionary!.containsKey(pName)) {
final IPdfPrimitive? pageRef = crosstable
.getObject(_helper.dictionary![PdfDictionaryProperties.p]);
if (pageRef != null && pageRef is PdfDictionary) {
final PdfReference widgetReference =
crosstable.getReference(_helper.dictionary);
for (int i = 0; i < doc.pages.count; i++) {
final PdfPage loadedPage = doc.pages[i];
final PdfArray? lAnnots =
PdfPageHelper.getHelper(loadedPage).obtainAnnotations();
if (lAnnots != null) {
for (int i = 0; i < lAnnots.count; i++) {
final IPdfPrimitive? holder = lAnnots[i];
if (holder != null &&
holder is PdfReferenceHolder &&
holder.reference != null &&
holder.reference!.objNum == widgetReference.objNum &&
holder.reference!.genNum == widgetReference.genNum) {
_page = PdfPageCollectionHelper.getHelper(doc.pages)
.getPage(pageRef);
helper.defaultIndex = backUpIndex;
return _page;
}
}
}
if (_helper.dictionary!
.containsKey(PdfDictionaryProperties.p)) {
final IPdfPrimitive? itemPageDict = PdfCrossTable.dereference(
_helper.dictionary![PdfDictionaryProperties.p]);
final PdfDictionary pageDict =
PdfPageHelper.getHelper(loadedPage).dictionary!;
if (itemPageDict is PdfDictionary &&
itemPageDict == pageDict) {
_page = loadedPage;
helper.defaultIndex = backUpIndex;
return _page;
}
}
}
helper.defaultIndex = backUpIndex;
_page = null;
}
} else {
final PdfReference widgetReference =
crosstable.getReference(_helper.dictionary);
for (int i = 0; i < doc.pages.count; i++) {
final PdfPage loadedPage = doc.pages[i];
final PdfArray? lAnnots =
PdfPageHelper.getHelper(loadedPage).obtainAnnotations();
if (lAnnots != null) {
for (int i = 0; i < lAnnots.count; i++) {
final IPdfPrimitive? holder = lAnnots[i];
if (holder != null &&
holder is PdfReferenceHolder &&
holder.reference!.objNum == widgetReference.objNum &&
holder.reference!.genNum == widgetReference.genNum) {
return _page = loadedPage;
}
}
}
}
_page = null;
}
}
}
helper.defaultIndex = backUpIndex;
}
return _page;
}